Forum Moderators: coopster
The table name is faqs...in that exact case(to rule out case-sensitive mistake).
It is giving me this as the error
Invalid query: No Database Selected
uhm... FROM faqs... isn't that selecting the db?
I have already connected using mysql_connect();
The login as localhost and everything is working correctly from what I can tell. Is this possibly the problem though? I use the connect with blank args, and this is connecting to a db on the local host.
Any thoughts?
$connect = mysql_connect("localhost");
if (!$connect) die ("Could not connect to MySQL");
$dbases = mysql_list_dbs($connect);
$num = mysql_num_rows($dbases);
for ($x = 0; $x < $num; $x++)
print mysql_tablename($dbases, $x)."<br>";
<?php
$connect = mysql_connect();
or die ("Could not connect to MySQL");
$db = mysql_select_db("adm", $connect);
$result = mysql_query("SELECT * FROM faqs")
or die("Invalid query: " . mysql_error());
mysql_close($connect);
?>
If you can log into mysql from a terminal..
1. Type "show databases;" to see the database names.
2. Make a note of the database(s) you think might be yours.
3. "Use database [databasename];"
4. "show tables"
You might consider using a database client utility that lets you see the structure of your mysql stuff. (e.g., YourSQL, which is free for MacOS X.)