I am sorry but I am just starting and I suck. I've been spending the last hour on the site trying to use others' threads and the FAQ to fix this but I simply have not been able to do so. This is real simple. All my code is..


include 'connect.php';

$get = mysql_query("SELECT * FROM songs");
while ($row = mysql_fetch_assoc($get))
 //get data
 $song = $row['song'];
 $rating = $row['rating'];

 echo "$song - $rating";



where connect.php has mysql_connect and mysql_select_db

and I get "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/rbnstuff/public_html/newlayout/index.php on line 6"

Probably, $get has NULL. Check the query again. And are you sure that the connection succeed ? Make sure your mysql_connect passed or not. Anyway, use the error handler.

mysql_connect($host, $user, $pass) or die('Couldn\'t connect to MySQL. Error: ' . mysql_error());

SELECT * FROM songs, check this query manually in PHPMyAdmin via the browser.

So I ended up replacing the username password type database stuff and it worked. I'm not sure why.

I ended up using this to make the rating system from phpacademy and am wondering how one would get it so an IP wouldn't be able to rate twice. Where should I go for this?

Member Avatar

Don't rely on IP - ISPs can change this without the user being aware, also many users can share the same IP. A user_id with a login system would be better.