Jump to content

php script returning error


jonsamwell

Recommended Posts

Hi all,

 

I am just learning php and have completed a tutorial inputing what the tutorial said but when i run the script i get the following errors. i am using MYSQL database on a localhost (my machine) and am positive i have the correct username and password for the server (wamp). i am running the script in 'www' directory as wamp instructs

 

errors:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'jonsamwell'@'localhost' (using password: YES) in C:\wamp\www\test\phptestquery.php on line 3
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\test\phptestquery.php on line 5
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\wamp\www\test\phptestquery.php on line 5
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\test\phptestquery.php on line 9
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\test\phptestquery.php on line 9
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\phptestquery.php on line 17
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\test\phptestquery.php on line 28

 

the code i have is as follows: -

<?PHP
//connection info
$conn = mysql_connect("localhost", "jonsamwell", "password");
//msql select database method
mysql_select_db("test1");
//define variables with $*
$query_all = 'SELECT * FROM ss_users';
//variable to contain result data
$results = mysql_query($query_all);
//create xml to read into flash echo=println
echo "<?xml version=\"1.0\?>\n";
//XML Root tag
echo "<All Users>\n";
//creates an array and returns result to variable in while loop
while ($results_array=mysql_fetch_assoc($results)) {
echo "<item>" . $results_array["User_ID"] . "</item>\n";
echo "<item>" . $results_array["User_Login_Name"] . "</item>\n";
echo "<item>" . $results_array["P_word"] . "</item>\n";
echo "<item>" . $results_array["Email"] . "</item>\n";
}
//close root tag
echo "</All Users>\n";
//close connection to db
mysql_close($conn);
?>

 

any ideas would be great!!

 

Thanks,

 

Jon

Link to comment
https://forums.phpfreaks.com/topic/121618-php-script-returning-error/
Share on other sites

check for the users... i am not familiar with the wamp server though as i am using xampp but i dont use phpmyadmin for that. if you have phpmyadmin you can check that. anyway, by default, you have a user with username 'root' and no password. you can use this in 'localhost' or '127.0.0.1' connection.

 

since you are on the learning process (as i suppose), you can use that but on real scenario you wouldn't do that. :)

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.