|
Posted by Sugapablo on 10/24/76 11:34
I have a small test script connecting to a MySQL database. It seems to
work, unless I try to use the resource link identifier returned by
mysql_connect();
This works and returns all the rows in the table:
<?php
include("../config.php");
$dbi = mysql_connect($dbhost,$dbuname,$dbpass);
mysql_select_db($dbname);
$res = mysql_query("SELECT * FROM temp_stories");
if($dbi)
echo "PASS<BR>";
else
echo "FAIL<BR>";
while($row = mysql_fetch_array($res)) {
echo $row['title']."<br/>";
}
?>
This does NOT work and returns no rows:
<?php
include("../config.php");
$dbi = mysql_connect($dbhost,$dbuname,$dbpass);
mysql_select_db($dbname);
$res = mysql_query("SELECT * FROM temp_stories",$dbi);
if($dbi)
echo "PASS<BR>";
else
echo "FAIL<BR>";
while($row = mysql_fetch_array($res)) {
echo $row['title']."<br/>";
}
?>
As you can see, the only change was including ",$dbi" in the mysql_query()
function.
Both scripts echo "FAIL" from the if($dbi) check, yet I do get the rows I
ask for when not including the resource link in mysql_query().
Any idea what's going on here? Everything worked fine before a server
upgrade (which I did not do and don't have the details on).
(Yes, I have tried including the resource link in the mysql_select_db()
function, but that too causes failure.)
No errors are echoed to the screen even using "or die(mysql_error())";
--
Sugapablo
http://www.sugapablo.net
[Back to original message]
|