Jump to content

[SOLVED] automatic display


girlzz

Recommended Posts

matric_no------>varchar

name-------->text

year---------->varchar

group-------------> int

session---------> varchar

id---------> int

i had made changes in my code but it return to 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 'block 2,, 2)' at line 1

 

$insertSQL2 = sprintf("INSERT INTO medic_registered_course (matric_no, name, sessi, `year`,`s_code`, `group`) VALUES ( %s, %s, %s, %s,%s, %s)",
                       GetSQLValueString($_GET['matric'], "varchar"),
                       GetSQLValueString($_GET['name'], "text"),
                       GetSQLValueString($_GET['sessi'], "varchar"),
                       GetSQLValueString($_GET['year'], "varchar"),
			        GetSQLValueString($_GET['txtHint'], "varchar"),
                       GetSQLValueString($_GET['group'], "int"));
				   

Link to comment
Share on other sites

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

 

you have no 

 

case"varchar":
$theValue = other code
break;

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.