Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- mysql_query($query) returns mysql_errno 0.
September 14, 2007, 7:58 pm
rate this thread
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
$result = mysql_query($query);
die ("Query failed. Your Query: " . $query . "
Returned Error Number: " ." ".mysql_errno() . " Error Detail-> " . m
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.
You have a semicolon here, ending the statement.
This brace is not connected to the previous conditional. Despite PHP not doing
block scoping, it does let you put redundant braces around blocks.
So this always runs, $result probably was valid, and mysql_errno tells you "no
there wasn't an error".
Andy Hassall :: firstname.lastname@example.org :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
- » Slow performance using strtotime on prior 1970 dates
- — Previous thread in » PHP Scripting Forum
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum