You are here: Help: mysql_connect() doesn't seem to return resource link indentifier. « PHP Programming Language « IT news, forums, messages
Help: mysql_connect() doesn't seem to return resource link indentifier.

Posted by Sugapablo on 10/18/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

 

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

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