You have an error in your SQL syntax
I used DataAssist to create the pages insert, delete, detail and results. I am able to use the insert page and I have checked my database and have seen the new inserted data in the table. However, I am no longer able to view the table from the database with all other pages.
I receive this error instead
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 'from, subject, message FROM message WHERE newsId = -1' at line 1
Here is the code from the detail page.
<?php require_once('Connections/messasg_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
if (!session_id()) session_start();
?>
<?php
$ParamnewsId_WADAmessage = "-1";
if (isset($_GET['newsId'])) {
$ParamnewsId_WADAmessage = (get_magic_quotes_gpc()) ? $_GET['newsId'] : addslashes($_GET['newsId']);
}
$ParamSessionnewsId_WADAmessage = "-1";
if (isset($_SESSION['WADA_Insert_message'])) {
$ParamSessionnewsId_WADAmessage = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_message'] : addslashes($_SESSION['WADA_Insert_message']);
}
$ParamnewsId2_WADAmessage = "-1";
if (isset($_GET['newsId'])) {
$ParamnewsId2_WADAmessage = (get_magic_quotes_gpc()) ? $_GET['newsId'] : addslashes($_GET['newsId']);
}
mysql_select_db($database_messasg_db, $messasg_db);
$query_WADAmessage = sprintf("SELECT newsId, date, from, subject, message FROM message WHERE newsId = %s OR ( -1= %s AND newsId= %s)", GetSQLValueString($ParamnewsId_WADAmessage, "int"),GetSQLValueString($ParamnewsId2_WADAmessage, "int"),GetSQLValueString($ParamSessionnewsId_WADAmessage, "int"));
$WADAmessage = mysql_query($query_WADAmessage, $messasg_db) or die(mysql_error());
$row_WADAmessage = mysql_fetch_assoc($WADAmessage);
$totalRows_WADAmessage = mysql_num_rows($WADAmessage);
?>
I included the code up to the first HTML code. How can I fix this error so that I can complete this website. It was working for me yesterday and when I needed to start over, it no longer worked.