napap
06-12-2011, 02:21 PM
Hi, i have been trying for 3 hours now to get one simple string of information from a mysql database using php. I have used the exact same code before by only changing the mysql command to other database information... i have tryed multiple codes without success.
Mysql returns syntax error like this: 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 'Key FROM pptable WHERE Username=dexter' at line 1
i have two files, includes/connection.php and process.php
Here is the content of both:
includes/connection.php:
<?php
// Below lines sets the information to connect to the database... change for use with your own information...
$host = "127.0.0.1";
$user = "root";
$password = "";
$database = "database";
$connect = mysql_connect($host, $user, $password) or die (mysql_error());
mysql_select_db($database) or die (mysql_error());
?>
process.php:
<?php
include("includes/connection.php");
$key ="";
$user = "";
$key = $_GET['key'];
$user = $_GET['user'];
if ($user == ""){
echo "<h3>* Was not able to gather user...<hr></h3>";
}
if ($key == ""){
echo "<h3>* Was not able to gather key...<h3><br><hr>";
}
$query = "SELECT Key FROM pptable WHERE Username=$user";
$query = mysql_query($query) or die (mysql_error());
echo $query;
?>
How can i fix this syntax error? ps. The mysql database is correctly configured...
Mysql returns syntax error like this: 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 'Key FROM pptable WHERE Username=dexter' at line 1
i have two files, includes/connection.php and process.php
Here is the content of both:
includes/connection.php:
<?php
// Below lines sets the information to connect to the database... change for use with your own information...
$host = "127.0.0.1";
$user = "root";
$password = "";
$database = "database";
$connect = mysql_connect($host, $user, $password) or die (mysql_error());
mysql_select_db($database) or die (mysql_error());
?>
process.php:
<?php
include("includes/connection.php");
$key ="";
$user = "";
$key = $_GET['key'];
$user = $_GET['user'];
if ($user == ""){
echo "<h3>* Was not able to gather user...<hr></h3>";
}
if ($key == ""){
echo "<h3>* Was not able to gather key...<h3><br><hr>";
}
$query = "SELECT Key FROM pptable WHERE Username=$user";
$query = mysql_query($query) or die (mysql_error());
echo $query;
?>
How can i fix this syntax error? ps. The mysql database is correctly configured...