[wplug] Semi OT: PHP mysql_connect() not returning resource link.

Chris Romano romano.chris at gmail.com
Wed Dec 14 14:19:36 EST 2005


On 12/14/05, Russ Schneider <russ at sugapablo.com> wrote:
>
> Semi-Off-Topic, since it MAY be a server config issue:
>
> 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 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/>";
> }
> ?>



Try putting "or die('Query failed: ' . mysql_error());" at the end of your
query statement.  ...
$res = mysql_query("SELECT * FROM temp_stories",$dbi) or die('Query failed:
' .mysql_error());

That will print any errors from mysql.

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.wplug.org/pipermail/wplug/attachments/20051214/6fbe0048/attachment.html


More information about the wplug mailing list