Nothadoth Posted July 3, 2007 Share Posted July 3, 2007 im using this code: $connect = mysql_connect('localhost','hidden','hidden'); mysql_select_db('westmids_site'); $querynav = mysql_query("SELECT * FROM nav"); if (!$connect) { print "Could not connect to database"; } elseif (!$querynav) { print "Could not find database table"; } else { $name = mysql_fetch_array($name); print "<table border='0'> <tr> <td width='12'>"; if($pagetitle = mysql_fetch_array($name)) { print "<img src='http://www.westmidspoliceclub.com/en/images/navon.gif'>"; } else { print "<img src='http://www.westmidspoliceclub.com/en/images/navoff.gif'>"; } print "</td> <td valign='middle'><b><span class='t2'>".$name."</span></b></td> </tr> </table>"; } Its returning my cannot find database table error. But the database table 'nav' exists. Can someone help? Link to comment https://forums.phpfreaks.com/topic/58199-connect-to-db-table-s/ Share on other sites More sharing options...
aniesh82 Posted July 3, 2007 Share Posted July 3, 2007 Use the following code and let me know the result: $connect = mysql_connect('localhost','hidden','hidden') or die("Could not connect to the Localhost"); mysql_select_db('westmids_site',$connect ) or die("Could not select Database"); May be your table exists in some other databses. Link to comment https://forums.phpfreaks.com/topic/58199-connect-to-db-table-s/#findComment-288627 Share on other sites More sharing options...
Nothadoth Posted July 3, 2007 Author Share Posted July 3, 2007 Could not select Database Link to comment https://forums.phpfreaks.com/topic/58199-connect-to-db-table-s/#findComment-288628 Share on other sites More sharing options...
Nothadoth Posted July 3, 2007 Author Share Posted July 3, 2007 Ive trial and error'd it and it connects via the username, password to the localhost. But it refuses to find the database, despite it being there. Can someone help? Link to comment https://forums.phpfreaks.com/topic/58199-connect-to-db-table-s/#findComment-288633 Share on other sites More sharing options...
AndyB Posted July 3, 2007 Share Posted July 3, 2007 Back to basics. Let's see the real error messages. What happens with this? $connect = mysql_connect('localhost','hidden','hidden') or die(mysql_error()); mysql_select_db('westmids_site',$connect ) or die(mysql_error()); $querynav = mysql_query("SELECT * FROM nav") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/58199-connect-to-db-table-s/#findComment-288665 Share on other sites More sharing options...
Nothadoth Posted July 3, 2007 Author Share Posted July 3, 2007 sorry, i sorted it Link to comment https://forums.phpfreaks.com/topic/58199-connect-to-db-table-s/#findComment-289242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.