mysql_query($query) returns mysql_errno 0.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hey all;

I'm one of those newbies to the PHP realm of programming and I've run
into a stumper.  What I'm trying to do is pull data (any data at this
point) from a mysql database.  I've checked and doublechecked by my
code and cross referenced examples on the Web, but I cannot seem to
find anything that might give me some incite.

Below is a code snippet showing what I'm trying to accomplish.

$connection = mysql_connect('localhost', 'user', 'pass');
                die ("Could not connect to the database: \n".
                print "Successfully connected to the database \n";
$db_select = mysql_select_db('self_serv');
                die ("Could not select the database: \n".
                print "Successfully selected the database \n";
$select = 'SELECT';
$column = '*';
$from = 'FROM';
$tables = 'app_n_port';
$where = 'WHERE app_no=1001';
$query = $select." ".$column." ".$from." ".$tables." ".$where. " LIMIT
0, 30";
$result = mysql_query($query);
if (!$result);
                die ("Query failed.  Your Query: " . $query . "
Returned Error Number: " ." ".mysql_errno() . " Error Detail-> " . m
ysql_error()). "\n";
while ($result_row = mysql_fetch_array($result))
                echo $result_row. "\n";

After running the script I get the "die" statement after the <if(!
$result) clause with no mysql_error and a mysql_errno of 0.

Any help would be greatly appreciated.

Thanks in advance,


Re: mysql_query($query) returns mysql_errno 0.

On Fri, 14 Sep 2007 19:58:25 -0000, wrote:

Quoted text here. Click to load it

 You have a semicolon here, ending the statement.

Quoted text here. Click to load it

 This brace is not connected to the previous conditional. Despite PHP not doing
block scoping, it does let you put redundant braces around blocks.

Quoted text here. Click to load it

 So this always runs, $result probably was valid, and mysql_errno tells you "no
there wasn't an error".

Andy Hassall :: :: :: disk and FTP usage analysis tool

Site Timeline