The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> PHP & MySQL
Sifo
post Apr 29 2015, 01:27 PM
Post #1





Group: Members
Posts: 1
Joined: 29-April 15
Member No.: 22,532



Hey
I'm stuck at this error in the coding

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

and im not sure what to do

This is the code

<?php require_once('Connections/kommentarkobling.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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO kommentar (tidsstempel, tittel, navn, tekst) VALUES (NOW(), (%s, %s, %s)",
GetSQLValueString($_POST['tittel'], "text"),
GetSQLValueString($_POST['navn'], "text"),
GetSQLValueString($_POST['tekst'], "text"));

mysql_select_db($database_kommentarkobling, $kommentarkobling);
$Result1 = mysql_query($insertSQL, $kommentarkobling) or die(mysql_error());
}

mysql_select_db($database_kommentarkobling, $kommentarkobling);
$query_kommentar = "SELECT DATE_FORMAT(tidsstempel,'%d/%m-%Y') AS 'dato', DATE_FORMAT(tidsstempel,'%H:%i') AS 'tid', tittel, navn, tekst FROM kommentar ORDER BY tidsstempel DESC";
$kommentar = mysql_query($query_kommentar, $kommentarkobling) or die(mysql_error());
$row_kommentar = mysql_fetch_assoc($kommentar);
$totalRows_kommentar = mysql_num_rows($kommentar);
?>

Appreciate any help i can get smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th March 2024 - 01:09 AM