SlyOne Posted February 16, 2009 Share Posted February 16, 2009 hi all, I seem to be getting 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 'FROM universities WHERE id = -1' at line 1 Been looking through my code and been fiddling around to find what i have done wrong but can't seem to find anything, was wondering if i could have a second set of eyes to look my code over and see if there is anything i have missed. I'm using wampserver version 2.0 Mysql version 5.1.30 If need be i'll provide the actual .sql file that is on my database, not much on there so let me know if its needed. As its saying from line 1, i'll include it all upto the last bit of my sql. <?php require_once('Connections/dsUniversity.php'); ?> <?php if (!function_exists("GetSQLValueString")) { 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_rsUniversityDetail = "-1"; if (isset($_GET['universityID'])) { $colname_rsUniversityDetail = $_GET['universityID']; } mysql_select_db($database_dsUniversity, $dsUniversity); $query_rsUniversityDetail = sprintf("SELECT id, uniName, shortName, bio, smImg, lgImg, FROM universities WHERE id = %s", GetSQLValueString($colname_rsUniversityDetail, "int")); $rsUniversityDetail = mysql_query($query_rsUniversityDetail, $dsUniversity) or die(mysql_error()); $row_rsUniversityDetail = mysql_fetch_assoc($rsUniversityDetail); $totalRows_rsUniversityDetail = mysql_num_rows($rsUniversityDetail); thanks for any help in advance Quote Link to comment https://forums.phpfreaks.com/topic/145441-solved-sql-syntax-errors-help/ Share on other sites More sharing options...
viion Posted February 16, 2009 Share Posted February 16, 2009 In your statement SELECT id, uniName, shortName, bio, smImg, lgImg, FROM universities WHERE Don't put the , after lgImg because it expects another value. Remove it "SELECT id, uniName, shortName, bio, smImg, lgImg FROM universities WHERE " Try that. Quote Link to comment https://forums.phpfreaks.com/topic/145441-solved-sql-syntax-errors-help/#findComment-763503 Share on other sites More sharing options...
SlyOne Posted February 16, 2009 Author Share Posted February 16, 2009 Ah cheers! Your a star, that has worked...completely missed it...feel like a plonka now. Been staring at it for hours trying to find what i had done wrong. thanks again Quote Link to comment https://forums.phpfreaks.com/topic/145441-solved-sql-syntax-errors-help/#findComment-763506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.