MYSQL Error not making sense


#1

mySQL Version: 5.0.32
PHP Version: 5.2.6
I have a query using standard Dreamweaver CS3 conventions thus:[code][color=#0000CC]

<?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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; } $colname_dlAttempts = "-1"; if (isset($_GET['vid'])) { $colname_dlAttempts = $_GET['vid']; } mysql_select_db($database_dlm, $dlm); $query_dlAttempts = sprintf("SELECT * FROM dl_attempts WHERE validationID = %s", GetSQLValueString($colname_dlAttempts, "text")); $dlAttempts = mysql_query($query_dlAttempts, $dlm) or die(mysql_error()); $row_dlAttempts = mysql_fetch_assoc($dlAttempts); $totalRows_dlAttempts = mysql_num_rows($dlAttempts); ?>[/color][/code]This is what the $query_dlAttempts echoes. It finds the query item when I use phpMyAdmin.

[color=#0000CC]SELECT * FROM dl_attempts WHERE validationID = 'b4d5f384fbd59cc114b4b749e8d6cfdc'[/color]But I get this when I try to use it from my application I get this:

[color=#0000CC]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 'b4d5f384fbd59cc114b4b749e8d6cfdc''' at line 1[/color]Of significance are the two extra single quotes after the validationID.

'b4d5f384fbd59cc114b4b749e8d6cfdc'[color=#0000CC]''[/color]<---- (two extra single quotes???)I’m out of ideas. Any help is greatly appreciated.