Mysql Error

liunx

Guest
In trying to learn this stuff, I thought I would try to implement this basic script that I copied from zend.com. I got past some of the errors I was getting, but can't get past this area. It is connecting to the database, but then won't get info from the table. Any help????<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$dbh=mysql_connect ($hs, $us, $ps)or die ('I cannot connect to the database because: '<br /> ? mysql_error());<br />mysql_select_db ($db);<br /><br />$query= "SELECT * FROM $tb"; <br />$query_result_handle = mysql_query ($query) <br />or die ('<h1><center>I cannot connect to the table because:</center></h1>'. mysql_error());<!--c2--></div><!--ec2--><br /><br />The error I get with the above code is MySQL syntax error. I changed the 6th line to "$sql=..." and got a "query empty" error. Oh...by the way...in the above code, $tb is defined in an included file. I tried putting the table name, but that didn't work either.<br /><br />Thanks,<br />Tracy<!--content-->
Read the following tutorial:<br /><br /><a href="http://www.devshed.com/Server_Side/PHP/DB_Basics/page1.html" target="_blank">http://www.devshed.com/Server_Side/PHP/DB_...sics/page1.html</a><br /><br />I'm telling you... if you're going to get heavy into PHP and MySQL... you're going to want to buy a book.<br /><br />I recommend PHP 4 Bible<!--content-->
Thanks for the link and book recommendation. I've got no problem buying a book and plan to do so soon. However, I live out in the boonies...about an hour and 45 minutes away from the closest place to buy such a book. Actually, I will probably buy online, but just haven't done it yet. <br /><br />Never fear...I do listen to "the ones in the know"!!! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />Thanks again,<br />Tracy<!--content-->
 
Top