Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
require_once 'head.php';
$query = "SELECT 'name', 'pass' FROM 'users'"; //ERROR HERE
if($run_query = mysql_query($query))
{
echo 'success';
}else
{
echo mysql_error();
}
?>

here is the return error
C++
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users'' at line 1


i tried to fix it and the new error im getting
C++
$query = "SELECT `name`, `pass` FROM `users`"; //Error: No database selected

C++
$query = "SELECT name, pass FROM users"; //Error: No database selected


what is wrong with the code ? any one can help pls ? thanks
im using the latest versio of xampp and also i tried the older version 1.7.4 but still doesnt work
Posted

1 solution

Well, have you selected a database?
See: http://php.net/manual/en/function.mysql-select-db.php[^]
 
Share this answer
 
Comments
Ronni2013 2-Apr-13 5:52am    
yes i did, it included on head.php
$mysql_db = "a_user";
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die('couldnt connect');
mysql_select_db($mysql_db) or die('couldnt connect to db');
Ronni2013 2-Apr-13 5:56am    
never mind i found my error it was on head.php...thanks
fixed it with
$query = "SELECT `name`, `pass` FROM `users`";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900