MySQL Forums
Forum List  »  PHP

Re: mysql_fetch_assoc(): supplied argument is not a valid MySQL error
Posted by: Barry Galbraith
Date: March 11, 2013 09:33PM

Like PB says, you need to test for errors.

Your error is that you don't have a database connection, you never called mysql_connect() and mysql_select_db().

Also, don't put quotes (or apostrophes) around your table name, or column name.
If you use a bad name like `table 2` with a space in it, then you must use back ticks, up there next to the 1 key. But do yourself a favour, and DON'T use spaces in a table or column name.

$server = "localhost"; // naam van de MySQL-databaseserver
$user = "root"; // inlognaam
$wachtwoord = "usbw"; //wachtwoord voor dit account
$database = "ict"; // naam van de database die we gebruiken
$link = mysql_connect($server,$user,$wachtwoord) or die(mysql_error());  //connect to the mysql server
mysql_select_db($database);  //select the database

$query = mysql_query("SELECT naam_toneelstuk, Gerne FROM `table 2` WHERE Gerne = 'toneel'") or die(mysql_error()); // de SQL-query die wordt uitgevoerd

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
Re: mysql_fetch_assoc(): supplied argument is not a valid MySQL error
March 11, 2013 09:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.