SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Database error?

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database error?

    Ok, I get this error:

    Database Error

    MySQL Error : Database Error
    Error Number: 1046 No Database Selected
    Date : Sat, January 29, 2005 11:51:48
    IP : xxx
    Browser : xxx
    Referer : http://cyber-wars.com/view.php?view=277
    PHP Version : 4.3.10
    OS : Linux
    Server : Apache
    Server Name : www.cyber-wars.com
    Script Name : /battle.php


    Its for a poll. It usally works on other pages, however, its only when you fight someone - maybe because it updates the database and the poll cant be shown because a mysql query is already been run?? Its only on battle.php when you fight someone.. :S
    If someone was helpful, give them some 'rep'.

  2. #2
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The error says it all - you have not selected a database to work with!!! Somewhere, after your call to mysql_connect and before any calls to mysql_query, you must call mysql_select_db

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I have, or I think I have.. it works on ALL other pages but this one... whats the matter? Its the same php include as im using headers / footers. !!!
    If someone was helpful, give them some 'rep'.

  4. #4
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try posting the code,and I'll take a look at it.

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <? include 'poll/poll.php'?>
    Poll/Poll.php:

    PHP Code:
    <?php 
    include xx/xx/xx/poll/poll_cookie.php';
    include xx/xx/xx/poll/include/config.inc.php'
    ;
    ?>
    <?php

    /* path */ 
    $poll_path xx/xx/public_html/";

    require 
    $poll_path."/poll/include/config.inc.php";
    require 
    $poll_path."/poll/include/$POLLDB[class]";
    require 
    $poll_path."/poll/include/class_poll.php";
    $CLASS["db"] = new polldb_sql;
    $CLASS["db"]->connect(); 

    $php_poll = new poll();

    /* the first poll */ 
    echo 
    $php_poll->poll_process(4);


    ?>
    If someone was helpful, give them some 'rep'.

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opps thats the wrong code

    PHP Code:
    <?php 
    include 'xx/xx/xx/poll/poll_cookie.php'
    include 
    'xx/xx/xx/poll/include/config.inc.php'
    ?> 
    <?php 

    /* path */ 
    $poll_path xx/xx/public_html/"; 

    require 
    $poll_path."/poll/include/config.inc.php"; 
    require 
    $poll_path."/poll/include/$POLLDB[class]"; 
    require 
    $poll_path."/poll/include/class_poll.php"; 
    $CLASS["db"] = new polldb_sql; 
    $CLASS["db"]->connect(); 

    $php_poll = new poll(); 

    /* the first poll */ 
    echo 
    $php_poll->poll_process(4); 


    ?>
    If someone was helpful, give them some 'rep'.

  7. #7
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GRR. $poll_path = "xx/xx/public_html/"; I just missed that out. Sorry for triple post!

    What a noob I Am :$
    If someone was helpful, give them some 'rep'.

  8. #8
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code you posted has errors.

    Here is my cleaned up version

    PHP Code:
      include 'xx/xx/xx/poll/poll_cookie.php';
      include 
    'xx/xx/xx/poll/include/config.inc.php';
      
      
    /* path */
      
    $poll_path 'xx/xx/public_html/';
      
      require 
    $poll_path 'poll/include/config.inc.php';
      require 
    $poll_path 'poll/include/' $POLLDB['class'];
      require 
    $poll_path 'poll/include/class_poll.php';
      
      
    $CLASS['db'] = new polldb_sql;
      
    $CLASS['db']->connect();
      
      
    $php_poll = new poll();
      
      
    /* the first poll */
      
    echo $php_poll->poll_process(4); 
    I need to see what the [b]polldb_sql[/b[ class looks like, and probably also what is in the config.inc.php file.

    It may have just been the fact that you had errors in the file, so try the changes I posted above.

    Also, you posted poll/poll.php but the error was shown in view.php, so you need to post view.php file.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •