[wplug] Semi OT: PHP mysql_connect() not returning resource link.
Chet Hosey
chosey at nauticom.net
Wed Dec 14 14:10:15 EST 2005
Russ Schneider wrote:
>Semi-Off-Topic, since it MAY be a server config issue:
>
>$res = mysql_query("SELECT * FROM temp_stories");
>
>
>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);
>
>
Nothing specific, but a few thoughts...
Try a phpinfo(INFO_MODULES); at various points in your script, to see
how many database connections are open at various points (specifically,
before and after: the include statement, your mysql_open() call, your
mysql_query() call). There's no simply way to only display mysql-related
info, so you'll have to search through the output. However, it's a good
way to be *sure* whether connections are open at various points.
What if you try mysql_connect() (without parameters)? According to PHP's
documentation, "If the link identifier is not specified, the last link
opened by *mysql_connect()*
<http://us3.php.net/manual/en/function.mysql-connect.php> is assumed. If
no such link is found, it will try to create one as if *mysql_connect()*
<http://us3.php.net/manual/en/function.mysql-connect.php> was called
with no arguments." Is it possible that an implicit connection attempt
(perhaps by the mysql_query statement) is succeeding?
Do your credentials work using the mysql client from a command line?
Someone on the PHP mysql_error() page |said, "If you want to display
errors like 'Access denied...', when mysql_error() returns '' and
mysql_errno() returns 0, use $php_errormsg. This Warning will be stored
there. You need to have track_errors set to true in your php.ini." It
might helpful to try to find warnings which aren't being shown.
General note:
The PHP website has a *really neat* 404 handler that'll automatically
search for content. Try http://www.php.net/cookies or
http://www.php.net/mysql_query for examples. It's the easiest way to
find something on PHP's site. I just wanted to share that, as it makes
using the site for reference fast and easy.
Good luck, and keep us updated!
Chet
|
More information about the wplug
mailing list