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
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.