Jump to content

[SOLVED] SQL syntax errors, help!


SlyOne

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/145441-solved-sql-syntax-errors-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.