High Scores - forgive this noob...

I have read through the excellent tutorial on the support wiki and tried to follow it to the letter, but nothing seems to work.
I successfully created a database (called ‘scores’) and even used the queries from the examples to populate it with some data directly from PHPmyAdmin.

I just can’t seem to get the .php pages to work! I stripped down the addscores.php to just the posting portion (I think) and it still won’t update the database.

Again, I am in pre-school when it comes to PHP so I am sure I forgot something! Here is the code I am using to test addscores.php:

<?php 
        mysql_connect('64.40.144.162', 'USER_scores', '****');
 
        mysql_select_db('scores');
 
        mysql_query(insert into scores values (NULL, Mark, 1501);
 
?>

I try loading the page and check the database but nothing has changed. I figure if I can get this working, then I can expand out to everything else.

I know my server uses PHP and I gave ‘USER_scores’ admin access to the database. I have tried this with both the IP address (as shown above) and the url.

I tried looking through a bunch of PHP tutorials and saw that some folks use a different syntax when selecting the database. But it seems most people here have gotten this to work.

Any ideas on what I am doing wrong? Is it something really fundimental like the fact that you can’t run .php scripts by just opening the page in a browser? (I hope not.)

Help!

Andrew

Here is my php code that I used for megapixel:

<?php
	$name = $_GET['name'];
	$level = $_GET['level'];
	$score = $_GET['score'];
	$kode = $_GET['kode'];

	$hashed = "$name$score$level";
	$hash = md5($hashed);
	if($hash == $kode)
	{
		// Send variables for the MySQL database class.
		$db = mysql_connect('mysql.yogware.bluegillstudios.com', 'theusername', '********') or die('Could not connect: ' . mysql_error());
		mysql_select_db('megapixel_scores') or die('Could not select database');
			
		$query = "insert into scores values (NULL, '$name', '$score', '$level');";
		$result = mysql_query($query) or die('Query failed: ' . mysql_error());
		
		echo 'success';
	}
	else
	{
		echo 'nice try, buddy';
	}
?>

I don’t know how it works really, but you could try simplifying mine and see if it works. One thing that I have that you don’t is printing the errors out. That might help for debugging.

Thanks for the code Yoggy!
I am able to see some of the errors now (although I could not using the code copied from the wiki - strange)

It keeps saying I cannot select the database.
I assume (big mistake) that I am connecting to my database, but cannot select the right table.
I have tried both

mysql_selectdb(‘scores’, ‘$db’)
and
mysql_select_db(‘scores’, ‘$db’)

Plus, of course the original:

mysql_select_db(‘scores’)

I rechecked my table name and it is ‘scores’. Is there anything else that might be causing the issue?

Thanks,
Andrew

In fact you’re not even connecting to your database here - it’s failing on finding the database, not on finding the proper table. Is scores also the name of the actual database? The table name only matters in the query - ie this line:
mysql_query(insert into scores values (NULL, Mark, 1501);

The database name may be something completely different - such as your login name, etc if you’re on hosted box somewhere.

That was it! It’s always something stupidly simple, isn’t it? Well…it’s simple AFTER someone else has cleared it up!
Thanks Matt!

Andrew