I'm using PHP version 5.4.12.
In scribblings_main.php (all html code), there's this code:
<a href="display_story.php?serial=17">Jan 26</a>
It calls a page to display a newspaper story from a single record with 'serial number' of 17.
If I hard code that number in the display page ($serial = 17;) it works perfectly; if I attempt to pass the variable 'serial' and try to retrieve it on the display page with $serial = $_GET['serial'] ; I get this error: "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"
Starting at line 1, and down to the $serial = $_GET['serial'] ; statement, there is this code:
<?php require_once('Connections/scribblings.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;
}
}
I have no idea what the error tells me. Can anyone see how this block of code might be screwing things up?
Here is the rest of the code:
$serial = $_GET['serial'] ;
$serial = is_int($serial);
mysql_select_db($database_scribblings, $scribblings);
$query_rsStory = "SELECT story FROM stories WHERE storyid = $serial";
$rsStory = mysql_query($query_rsStory, $scribblings) or die(mysql_error());
$row_rsStory = mysql_fetch_assoc($rsStory);
$totalRows_rsStory = mysql_num_rows($rsStory);
mysql_free_result($rsStory);
?>