You are here: mysql_query($query) returns mysql_errno 0. « PHP Programming Language « IT news, forums, messages
mysql_query($query) returns mysql_errno 0.

Posted by thad.irvin on 09/14/07 19:58

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.

<?php
$connection = mysql_connect('localhost', 'user', 'pass');
if(!$connection)
{
die ("Could not connect to the database: \n".
mysql_error());
}
elseif($connection)
{
print "Successfully connected to the database \n";
}
$db_select = mysql_select_db('self_serv');
if(!$db_select)
{
die ("Could not select the database: \n".
mysql_error());
}
elseif($db_select)
{
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";
}
mysql_close($connection);
?>

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,

Thad

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация