Current location: Hot Scripts Forums » Other Discussions » Database » error in MySQL in PHP with Dreamweaver


error in MySQL in PHP with Dreamweaver

Reply
  #1 (permalink)  
Old 06-03-11, 05:45 PM
wziadi wziadi is offline
New Member
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
error in MySQL in PHP with Dreamweaver

hi
i made a registration form in a website using dreamweaver
i made the database in the remote server, then linked it to the registration page via dreamweaver
i tested the database connection, and it was successful
then i made the form via insert record set in dreamweaver
i uploaded the page to the remote server and tried to enter some data to send it but after i filled the data, and pressed the send button, i got this error message:
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 '' at line 1


this is the code i use
PHP Code:

<?php require_once("Connections/con1.php"); ?>

<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO students (StuID, ProName, Name1, Name2, Name3, Mob#, Phone#, Email, BirthYear, `Level`, FathName, FathMob#, MothName, MothMob#) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['StuID'], "int"),
                       
GetSQLValueString($_POST['ProName'], "text"),
                       
GetSQLValueString($_POST['Name1'], "text"),
                       
GetSQLValueString($_POST['Name2'], "text"),
                       
GetSQLValueString($_POST['Name3'], "text"),
                       
GetSQLValueString($_POST['Mob'], "int"),
                       
GetSQLValueString($_POST['Phone'], "int"),
                       
GetSQLValueString($_POST['Email'], "text"),
                       
GetSQLValueString($_POST['BirthYear'], "int"),
                       
GetSQLValueString($_POST['Level'], "text"),
                       
GetSQLValueString($_POST['FathName'], "text"),
                       
GetSQLValueString($_POST['FathMob'], "int"),
                       
GetSQLValueString($_POST['MothName'], "text"),
                       
GetSQLValueString($_POST['MothMob'], "int"));

  
mysql_select_db($database_con1$con1);
  
$Result1 mysql_query($insertSQL$con1) or die(mysql_error());
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO students (StuID, Name1, Name2, Name3, Mob#, Phone#, Email, BirthYear, `Level`, FathName, FathMob#, MothName, MothMob#, ProName) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['StuID'], "int"),
                       
GetSQLValueString($_POST['Name1'], "text"),
                       
GetSQLValueString($_POST['Name2'], "text"),
                       
GetSQLValueString($_POST['Name3'], "text"),
                       
GetSQLValueString($_POST['Mob'], "int"),
                       
GetSQLValueString($_POST['Phone'], "int"),
                       
GetSQLValueString($_POST['Email'], "text"),
                       
GetSQLValueString($_POST['BirthYear'], "int"),
                       
GetSQLValueString($_POST['Level'], "text"),
                       
GetSQLValueString($_POST['FathName'], "text"),
                       
GetSQLValueString($_POST['FathMob'], "int"),
                       
GetSQLValueString($_POST['MothName'], "text"),
                       
GetSQLValueString($_POST['MothMob'], "int"),
                       
GetSQLValueString($_POST['ProName'], "text"));

  
mysql_select_db($database_con1$con1);
  
$Result1 mysql_query($insertSQL$con1) or die(mysql_error());
}

mysql_select_db($database_con1$con1);
$query_Recordset1 "SELECT * FROM programs";
$Recordset1 mysql_query($query_Recordset1$con1) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

mysql_select_db($database_con1$con1);
$query_Recordset2 "SELECT * FROM prostatus";
$Recordset2 mysql_query($query_Recordset2$con1) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);

mysql_select_db($database_con1$con1);
$query_Recordset3 "SELECT * FROM students";
$Recordset3 mysql_query($query_Recordset3$con1) or die(mysql_error());
$row_Recordset3 mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 mysql_num_rows($Recordset3);

mysql_select_db($database_con1$con1);
$query_Recordset4 "SELECT * FROM stulevel";
$Recordset4 mysql_query($query_Recordset4$con1) or die(mysql_error());
$row_Recordset4 mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 mysql_num_rows($Recordset4);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl" xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/bodyTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<!-- InstanceBeginEditable name="doctitle" -->
<title>مركز دار الإكليل للفتيات</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
<div id="alekleel">

<div id="head1"></div>
<div id="head2"></div>
<div id="head3"></div>

<div id="frameLeft1"></div>

<div id="headNavBar1"><a href="about.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/333.png',1)"><img src="http://www.hotscripts.com/forums/images/14.png" name="Image6" width="100" height="46" border="0" id="Image6" /></a></div>

<div id="headNavBar2"><a href="gallery.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/222.png',1)"><img src="http://www.hotscripts.com/forums/images/13.png" name="Image5" width="100" height="46" border="0" id="Image5" /></a></div>

<div id="headNavBar3"> <a href="contact.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/111.png',1)"><img src="http://www.hotscripts.com/forums/images/12.png" name="Image4" width="100" height="46" border="0" id="Image4" /></a><a href="http://www.alekleel.net/contact.html"> </a></div>

<div id="headNavBar4"> <a href="registration.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','images/112-112.png',1)"><img src="http://www.hotscripts.com/forums/images/112.png" name="Image7" width="100" height="46" border="0" id="Image7" /></a><a href="http://www.alekleel.net/registration.php"> </a></div>

<div id="headNavBar5"> <a href="visitors.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','images/11_11.png',1)"><img src="http://www.hotscripts.com/forums/images/11.png" name="Image8" width="100" height="46" border="0" id="Image8" /></a><a href="http://www.alekleel.net/visitors.html"> </a></div>

<div id="headNavBar6"></div>
<div id="headNavBar7"></div>
<div id="headNavBar8"></div>
<div id="frameRight1"></div>

<div id="line2"></div>

<div id="line31"></div>
<div id="line32"></div>
<!-- InstanceBeginEditable name="EditRegion3" -->
<div id="body">
<div id="tablestyle"> 
<br />
<font color="#FF0000"> 
جميع البيانات مطلوبة لذا يرجى التأكد من تعبئتها قبل الإرسال
</font><br /><br />
  <form action="<?php echo $editFormAction?>" method="post" name="form1" id="form1">
    <table align="center">
      <tr valign="baseline">
        <td width="79" height="25" align="right" nowrap="nowrap"><div align="left">اسم البرنامج: </div></td>
         <td width="192"><select name="ProName">
          <option value="إكليل الصيف" <?php if (!(strcmp("إكليل الصيف"""))) {echo "SELECTED";} ?>>إكليل الصيف</option>
          </select></td>
         <td width="26">&nbsp;</td>
        <td width="81" align="right" nowrap="nowrap"><div align="left">سنة الميلاد:</div></td>
        <td width="192"><input type="text" name="BirthYear" value="" size="32" /></td>
        </tr>
      <tr valign="baseline">
        <td height="25" nowrap="nowrap" align="right"><div align="left">الاسم الأول: </div></td>
        <td><input type="text" name="Name1" value="" size="32" /></td>
        <td>&nbsp;</td>
        <td align="right" nowrap="nowrap"><div align="left">المرحلة الدراسية:</div></td>
        <td><select name="Level">
          <option value="متوسط" <?php if (!(strcmp("متوسط"""))) {echo "SELECTED";} ?>>متوسط</option>
          <option value="ثانوي" <?php if (!(strcmp("ثانوي"""))) {echo "SELECTED";} ?>>ثانوي</option>
          <option value="جامعي" <?php if (!(strcmp("جامعي"""))) {echo "SELECTED";} ?>>جامعي</option>
          <option value="فوق الجامعي" <?php if (!(strcmp("فوق الجامعي"""))) {echo "SELECTED";} ?>>فوق الجامعي</option>
          </select></td>
      </tr>
      <tr valign="baseline">
        <td height="25" nowrap="nowrap" align="right"><div align="left">اسم الأب:</div></td>
        <td><input type="text" name="Name2" value="" size="32" /></td>
        <td>&nbsp;</td>
        <td align="right" nowrap="nowrap"><div align="left">اسم ولي الأمر</div></td>
        <td><input type="text" name="FathName" value="" size="32" /></td>
        </tr>
      <tr valign="baseline">
        <td height="25" nowrap="nowrap" align="right"><div align="left">اسم العائلة:</div></td>
        <td><input type="text" name="Name3" value="" size="32" /></td>
        <td>&nbsp;</td>
        <td align="right" nowrap="nowrap"><div align="left">رقم جواله:</div></td>
        <td><input type="text" name="FathMob" value="" size="32" /><br />
        <font color="#999999"; size="-2">
        يجب إدخال الرقم بالصيغة الدولية ، مثال 9665000000000</font></td>
        </tr>
      <tr valign="baseline">
        <td height="30" nowrap="nowrap" align="right"><div align="left">رقم الجوال:</div></td>
        <td><input type="text" name="Mob" value="" size="32" /><br />
        <font color="#999999"; size="-2">
        يجب إدخال الرقم بالصيغة الدولية ، مثال 9665000000000</font></td>
        <td>&nbsp;</td>
        <td align="right" nowrap="nowrap"><div align="left">اسم ولية الأمر:</div></td>
        <td><input type="text" name="MothName" value="" size="32" /></td>
        </tr>
      <tr valign="baseline">
        <td height="30" nowrap="nowrap" align="right"><div align="left">رقم الهاتف:</div></td>
        <td><input type="text" name="Phone" value="" size="32" />
        <br />
        <font color="#999999"; size="-2">
        يجب إدخال الرقم بالصيغة الدولية ، مثال 96610000000</font></td>
        <td>&nbsp;</td>
        <td align="right" nowrap="nowrap"><div align="left">رقم جوالها:</div></td>
        <td><input type="text" name="MothMob" value="" size="32" /><br />
        <font color="#999999"; size="-2">
        يجب إدخال الرقم بالصيغة الدولية ، مثال 9665000000000</font></td>
        </tr>
      <tr valign="baseline">
        <td height="25" nowrap="nowrap" align="right"><div align="left">البريد الإلكتروني:</div></td>
        <td><input type="text" name="Email" value="" size="32" /></td>
        <td>&nbsp;</td>
        <td><div align="left"></div></td>
        <td><div align="center">
          <input type="submit" value="إرسال" />
        </div></td>
      </tr>
    </table>
    <input type="hidden" name="StuID" value="" />
    <input type="hidden" name="MM_insert" value="form1" />
  </form>
  <p>&nbsp;</p>
  </div>
</div>
<!-- InstanceEndEditable -->
<div id="line33"></div>
<div id="line34"></div>

<div id="line4"></div>






<div id="bottom1"></div>
<div id="bottom2"></div>
<div id="bottom3"></div>

<div id="leftspace"></div>
<div id="icon1"></div>

<div id="icon2"> <a href="http://alekleel.net/vb/forumdisplay.php?f=3" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image9','','images/171717.png',1)"><img src="http://www.hotscripts.com/forums/images/47.png" name="Image9" width="100" height="56" border="0" id="Image9" /></a></div>

<div id="icon3"> <a href="http://www.facebook.com/pages/%D9%85%D8%B1%D9%83%D8%B2-%D8%A7%D9%84%D8%A5%D9%83%D9%84%D9%8A%D9%84-Al-Ekleel-Center/164453263583578?tour=1&amp;sk=wall" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','images/161616.png',1)"><img src="http://www.hotscripts.com/forums/images/46.png" name="Image10" width="100" height="56" border="0" id="Image10" /></a></div>

<div id="icon4"> <a href="http://twitter.com/#!/alekleel_net" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image11','','images/151515.png',1)"><img src="http://www.hotscripts.com/forums/images/45.png" name="Image11" width="100" height="56" border="0" id="Image11" /></a></div>

<div id="icon5"> <a href="http://www.youtube.com/user/alekleelnet" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image12','','images/141414.png',1)"><img src="http://www.hotscripts.com/forums/images/44.png" name="Image12" width="100" height="56" border="0" id="Image12" /></a></div>

<div id="icon6"> <a href="http://www.flickr.com/photos/alekleel/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image13','','images/131313.png',1)"><img src="http://www.hotscripts.com/forums/images/43.png" name="Image13" width="100" height="56" border="0" id="Image13" /></a></div>

<div id="icon7"> <a href="http://www.formspring.me/alekleelnet" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image14','','images/121212.png',1)"><img src="http://www.hotscripts.com/forums/images/42.png" name="Image14" width="100" height="56" border="0" id="Image14" /></a></div>

<div id="icon8"> <a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image15','','images/4141.png',1)"><img src="http://www.hotscripts.com/forums/images/41.png" name="Image15" width="100" height="56" border="0" id="Image15" /></a></div>

<div id="righspace"></div>

<div id="footer1"></div>
<div id="footer2"></div>
<div id="footer3"></div>

<div align="center">
<table>
<tr>
<!-- Histats.com  START (html only)-->
<a href="http://www.histats.com" alt="page hit counter" target="_blank" >
<embed src="http://s10.histats.com/389.swf"  flashvars="jver=1&acsid=1415949&domi=4"  quality="high"  width="112" height="48" name="389.swf"  align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" /></a>
<img  src="http://sstatic1.histats.com/0.gif?1415949&101" alt="web hit counter" border="0">
<!-- Histats.com  END  -->
</tr>
</table>
</div>

</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result
($Recordset1);

mysql_free_result($Recordset2);
?>

Last edited by UnrealEd; 06-03-11 at 06:02 PM.
Reply With Quote
  #2 (permalink)  
Old 06-03-11, 06:08 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
You'll have to narrow your code down to the part where the error occured. Right now I counted 6 different mysql_query calls that all might result in such an error.

Also, before running the query, check the value of the variable holding the query by outputting it. The error is way to general for us to tell you exactly what might be the cause of the issue. If you output the query, you might see a mistake in the query, one you might oversee when "programming" the query.
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 07-09-11, 02:10 PM
nafirici nafirici is offline
Newbie Coder
 
Join Date: Mar 2011
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
you should also try to echo out the queries after you build the query to see if you can figure out what look wrong. If you can't figure it out, post the built query that is causing the issue here.
__________________
Nafirici | MN Real Estate
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WEB HOSTING - $4.99/MONTH For 1GB HD & 25GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 10-20-05 07:26 AM
Complex mysql sorting pb (Get cat_list from cids &pcids with 1 query, willing to pay) aqw PHP 1 06-23-05 07:02 PM
How to get PHP to input data into a MYSQL table? scl789 PHP 5 04-21-05 09:06 PM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 2 11-12-04 03:25 PM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 10-30-04 01:19 PM


All times are GMT -5. The time now is 05:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.