View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

You have an error in your SQL syntax

Thread began 10/05/2009 11:05 am by tobyandjenny375881 | Last modified 10/05/2009 5:10 pm by tobyandjenny375881 | 756 views | 2 replies

tobyandjenny375881

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.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...