So I just started MySQL and SQL today, using SQLyog. Pretty cool stuff. Using a tutorial I found online, however im getting an error.. Here is the code.
PHP Code:
<?
$host = 'localhost';
$user = 'root';
$pass = 'password';
$database = 'roscripts';
$connect = @mysql_connect ( $host, $user, $pass ) ;
$sql = "SELECT * FROM `articles` WHERE `ID` = " . mysql_real_escape_string ( $_GET['ID'] );
mysql_select_db ( $database, $connect );
if ( @mysql_query ( $sql ) )
{
$query = mysql_query ( $sql );
$row = mysql_fetch_assoc ( $query );
echo $row['ID'] . '<br />' . $row['article_title'] . '<br />' . $row['article_content'];
}
else {
die ( mysql_error () );
}
?>
When I put that in the page, I get this error..
Quote:
|
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 '' at line 1
|
Whats the right suntax? I have the latest version of everything, I am using Apache2triad.
Thanks guys!