Jump to content

[SOLVED] syntax error


jeff5656

Recommended Posts

Hello,

I have this error with this code:

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 'bbb, svt, t_wave, q_wave, lad, v_tach, pvc, cardiomyopathy, mri, pet, c' at line 1

 

<?php require('secure.php'); 


include ("connectdb.php");

// grab the variables from the form

$mrn_pre = mysql_real_escape_string($_POST['mrn']);
$mrn = ereg_replace("[^A-Za-z0-9]", "", $mrn_pre);


$l_name= mysql_real_escape_string($_POST['l_name']);
$f_name= mysql_real_escape_string($_POST['f_name']); 
$dob= mysql_real_escape_string($_POST['dob']);
$enroll_date= mysql_real_escape_string($_POST['enroll_date']); 
$dx= mysql_real_escape_string($_POST['dx']);
$uveitis= mysql_real_escape_string($_POST['uveitis']);  
$optic= mysql_real_escape_string($_POST['optic']);  
$renal= mysql_real_escape_string($_POST['renal']);  
$hyperca= mysql_real_escape_string($_POST['hyperca']);  
$alkphos= mysql_real_escape_string($_POST['alkphos']);  
$t_bili= mysql_real_escape_string($_POST['t_bili']);  
$ast_alt= mysql_real_escape_string($_POST['ast_alt']);  
$anemia= mysql_real_escape_string($_POST['anemia']);  
$plts= mysql_real_escape_string($_POST['plts']);  
$wbc= mysql_real_escape_string($_POST['wbc']);  
$dyspnea= mysql_real_escape_string($_POST['dyspnea']);  
$cough= mysql_real_escape_string($_POST['cough']);  
$spiro_date = mysql_real_escape_string($_POST['spiro_date']);  
$dlco= mysql_real_escape_string($_POST['dlco']);  
$chest_pain= mysql_real_escape_string($_POST['chest_pain']);  
$syncope= mysql_real_escape_string($_POST['syncope']);  
$dizzy= mysql_real_escape_string($_POST['dizzy']);  
$palp= mysql_real_escape_string($_POST['palp']);  
$edema= mysql_real_escape_string($_POST['edema']);  
$doe= mysql_real_escape_string($_POST['doe']);  
$ekg_date= mysql_real_escape_string($_POST['ekg_date']);  
$hrt_blk = mysql_real_escape_string($_POST['hrt_blk']);
$bbb = mysql_real_escape_string($_POST['bbb']); 
$svt= mysql_real_escape_string($_POST['svt']);  
$t_wave= mysql_real_escape_string($_POST['t_wave']);  
$q_wave= mysql_real_escape_string($_POST['q_wave']);  
$lad= mysql_real_escape_string($_POST['lad']);  
$v_tach= mysql_real_escape_string($_POST['v_tach']);  
$pvc= mysql_real_escape_string($_POST['pvc']);  
$cardiomyopathy= mysql_real_escape_string($_POST['cardiomyopathy']);  
$mri= mysql_real_escape_string($_POST['mri']);  
$pet= mysql_real_escape_string($_POST['pet']);  
$card_comments= mysql_real_escape_string($_POST['card_comments']);  
$skin_bx= mysql_real_escape_string($_POST['skin_bx']); 
$pernio= mysql_real_escape_string($_POST['pernio']);  
$nodosum= mysql_real_escape_string($_POST['nodosum']);  
$annular= mysql_real_escape_string($_POST['annular']);  
$mac_pap= mysql_real_escape_string($_POST['mac_pap']);  
$new_nodule= mysql_real_escape_string($_POST['new_nodule']);  
$keloid= mysql_real_escape_string($_POST['keloid']);  
$pigment= mysql_real_escape_string($_POST['pigment']);  
$derm_comments= mysql_real_escape_string($_POST['derm_comments']); 
$headache= mysql_real_escape_string($_POST['headache']);  
$visual= mysql_real_escape_string($_POST['visual']);  
$droopy= mysql_real_escape_string($_POST['droopy']);  
$voice= mysql_real_escape_string($_POST['voice']);  
$numb= mysql_real_escape_string($_POST['numb']);  
$muscle= mysql_real_escape_string($_POST['muscle']);  
$balance= mysql_real_escape_string($_POST['balance']);  
$neuro_comments= mysql_real_escape_string($_POST['neuro_comments']);  
$cxr_date= mysql_real_escape_string($_POST['cxr_date']);  
$stage= mysql_real_escape_string($_POST['stage']);  
$ct_date= mysql_real_escape_string($_POST['ct_date']);  
$ct_thick= mysql_real_escape_string($_POST['ct_thick']);  
$bronchovasc = mysql_real_escape_string($_POST['bronchovasc']);  
$parench = mysql_real_escape_string($_POST['parench']);  
$ip_nodules = mysql_real_escape_string($_POST['ip_nodules']);  
$septal = mysql_real_escape_string($_POST['septal']);  
$pleural= mysql_real_escape_string($_POST['pleural']);  
$ln_enlarge= mysql_real_escape_string($_POST['ln_enlarge']);  
$rad_comments = mysql_real_escape_string($_POST['rad_comments']); 



$query = "INSERT INTO icu (id_incr, l_name,  f_name,  mrn,  dob, enroll_date, dx,  uveitis,  optic,  renal,  hyperca,  alkphos,  t_bili,  ast_alt,  anemia,  plts,  wbc,  dyspnea,  cough,  spiro_date ,  dlco,  chest_pain,  syncope,  dizzy,  palp,  edema,  doe,  ekg_date,  hrt_blk  bbb, svt,  t_wave,  q_wave,  lad,  v_tach,  pvc,  cardiomyopathy,  mri,  pet,  card_comments,  skin_bx, pernio,  nodosum,  annular,  mac_pap,  new_nodule,  keloid,  pigment,  derm_comments, headache,  visual,  droopy,  voice,  numb,  muscle,  balance,  neuro_comments,  cxr_date,  stage enum,  ct_date,  ct_thick,  bronchovasc ,  parench ,  ip_nodules ,  septal ,  pleural enum,  ln_enlarge,  rad_comments)

VALUES('$id_incr','$l_name',  '$f_name',  '$mrn',  '$dob', '$enroll_date', '$dx',  '$uveitis',  '$optic',  '$renal',  '$hyperca',  '$alkphos',  '$t_bili',  '$ast_alt',  '$anemia',  '$plts',  '$wbc',  '$dyspnea',  '$cough',  '$spiro_date ',  '$dlco',  '$chest_pain',  '$syncope',  '$dizzy',  '$palp',  '$edema',  '$doe',  '$ekg_date',  '$hrt_blk  '$bbb', '$svt',  '$t_wave',  '$q_wave',  '$lad',  '$v_tach',  '$pvc',  '$cardiomyopathy',  '$mri',  '$pet',  '$card_comments',  '$skin_bx', '$pernio',  '$nodosum',  '$annular',  '$mac_pap',  '$new_nodule',  '$keloid',  '$pigment',  '$derm_comments', '$headache',  '$visual',  '$droopy',  '$voice',  '$numb',  '$muscle',  '$balance',  '$neuro_comments',  '$cxr_date',  '$stage',  '$ct_date',  '$ct_thick',  '$bronchovasc ',  '$parench ',  '$ip_nodules ',  '$septal ',  '$pleural',  '$ln_enlarge',  '$rad_comments')";

mysql_query($query) or die(mysql_error());

echo "Patient added to list";
header("Location: displayactive.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/141504-solved-syntax-error/
Share on other sites

"The syntax error was in your query, not your php. "

 

Ok but in my php code a comma was missing which produced a syntax error.  A user correctly pointed this out and then I changed my php code and the problem was solved.  So...I'm not exactly sure what you are driving at?

Link to comment
https://forums.phpfreaks.com/topic/141504-solved-syntax-error/#findComment-740707
Share on other sites

I'm pointing out the fact that the error you got...

 

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 'bbb, svt, t_wave, q_wave, lad, v_tach, pvc, cardiomyopathy, mri, pet, c' at line 1

 

is a mysql error, not a php error. Next time you see a similar error you need to be aware that the error is in your query, not your php. In your code, $query holds a perfectly valid php string, however, when you pass that string to mysql it chokes. Why? Because it is syntactically incorrect sql.

Link to comment
https://forums.phpfreaks.com/topic/141504-solved-syntax-error/#findComment-740710
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.