Jump to content

connect to db table :S


Nothadoth

Recommended Posts

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

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.