Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling all MYSQL Gurus

Status
Not open for further replies.

vincentms

Programmer
May 4, 2003
1
CH
Hi all,

Please help...Why do I get "Query fail"? I put in a bogus password and I get "I cannot connect to the database". Is it safe to "assume" that when I use the correct password and I am connecting not getting the "cannot connect" msg that I am connecting OK?

Assuming, I am connecting OK I dont know why the Query Fails. Also, can I do a command like "show tables" to see that I am using the correct table name. Of course I know this is the name I used when I did Create Table.

I am stuck.

<html>
<body>

<?php
$db = mysql_connect(&quot;localhost&quot;, &quot;sdhz_fred&quot;, &quot;m3046&quot;) or die(&quot;I cannot connect to the database&quot;);
mysql_select_db(&quot;sdhz_bahgdad&quot;,$db);
$query = &quot;select * from questions&quot;;
$result = mysql_query($query) or die(&quot;Query fail&quot;);
printf(&quot;The Question: %s<br>\n&quot;, mysql_result($result,0,&quot;question&quot;));
?>

</body>
</html>


 
Change
[tt] $result = mysql_query($query) or die(&quot;Query fail&quot;);[/tt]
to
[tt] $result = mysql_query($query) or die(&quot;Query fail: &quot; . mysql_error());[/tt]
for easier debugging.

//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top