Mysql syntax error; yet again!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Mysql syntax error; yet again!

Post by cap2cap10 »

Greetings php Technorati. Ok, here I am again picking your brains for simple answers for ignorant mistakes on my part. That being said, please enlighten me on this current mysql syntax problem. When the page loads(job_app.php) it, browser only reads the header(location) information and jumps to the next page (p_series.php). Perplexing, I can't tell if there is an error in concatenation, but I know that there is nothing wrong with the require or include files because they function properly on other pages. Here is the code:

Code: Select all

<?php
$candidateID = $_GET['candidateID'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <TITLE>Welcome to the Preliminiary Interiew Series</TITLE>
<link rel="icon" href="images/logo1.png" type="image/png">
<link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<BODY>
<table border="0" width="1000">
<tr>
  <td width="323" rowspan="2" align="left" valign="top"><? include 'holiday_logo.php' ?></td>
</tr></table><BR>

<table border="0" cellspacing="0" cellpadding="0" height="25" width="1000" background="images/menu.jpg">
    <tr><td class="menus" style="padding-left: 18px;" width="450"><span class="menu">Welcome to the Preliminary Interiew Series</span></td>
    <td width="4" height="24" align="left" valign="top"><img src="images/menu_separater.gif" width="3" height="24"></td>
      <td width="150" height="24" align="center" valign="middle" class="menu" ><? print(Date("F d, Y")); ?></td>

</tr></table><BR>
<table border="0" width="600" cellspacing="0" cellpadding="0">
<tr>
  <td align="center"><fieldset><legend><span class="style12">Choose Category!</span></legend>
 <table border="0" width="600">
<tr>
  <td align="left" valign="middle"><img src="../images/arrow_orange.gif" width="14" height="14" border="0"><span class="style1">What position are you applying for?</span><BR>

  <form method="POST" action="job_app.php">
  <select name="interv">
  <option value=></option>
  <option value=q_admin_assist>Administrative Assistant</option>
   <option value=q_acc>Accountant</option>
   <option value=q_biz_analyst>Business Analyst</option>
   <option value=q_biz_manag>Business Manager</option>
   <option value=q_CEO>Chief Executive Officer</option>
   <option value=q_chief_fin_officer>Chief Financial Officer</option>
   <option value=q_CIO>Chief Information Officer</option>


   <option value=q_help_desk>Computer Help Desk</option>
   <option value=q_comp_prog>Computer Programmer</option>

   <option value=q_cust_serv>Customer Service</option>
   <option value=q_db_manag>Database Manager</option>
   <option value=q_dir>Director</option>
   <option value=q_exec_assist>Executive Assistant</option>
   <option value=q_flight_attend>Flight Attendant</option>
   <option value=q_fin_analyst>Financial Analyst</option>
   <option value=q_finan_manag>Finance Manager</option>
   <option value=q_gen_manag>General Manager</option>

   <option value=q_info_tech>Information Architect</option>
   <option value=q_market_manag>Marketing Manager</option>
   <option value=q_med_ass>Medical Assistant</option>
   <option value=q_med_biller>Medical Biller</option>

   <option value=q_med_tech>Medical Technician</option>


   <option value=q_net_admin>Network Administrator</option>
   <option value=q_pharm_tech>Pharmacy Technician</option>



   <option value=q_dent_tech>Dental Technician</option>

   <option value=q_nurse_aide>Nurse Aide</option>



   <option value=q_proj_manag>Project Management</option>
   <option value=q_supervise>Supervisor</option>


   <option value=q_sales_rep>Sales Representative</option>

   <option value=q_secretary>Secretary</option>
    <option value=q_reception>Receptionist</option>
    <option value=q_RN>Registered Nurse</option>
    <option value=q_x-ray_tech>X-Ray Technician</option>
    <option value=></option>
    <option value=></option>
    <option value=></option>
   <option value=></option></select></td>
  <td align="center" valign="bottom">
  <input type=hidden name=candidateID value=<?php echo $candidateID ?>/>
  <input type=hidden name=submit_1 value=true />
  <input type="submit" value="SUBMIT">
  </form>
<?php
if (isset($_POST['submit_1']) )
{
require_once  'open_db.php';
mysql_query("UPDATE prelim_db SET interv = '$interv' WHERE candidateID = '$candidateID'")or die('Query failed: ' . mysql_error());
}
mysql_close();
header("Location: p_series.php");
?></td>
</tr>
</table>
</fieldset></td></tr>
</table><p>

<table border="0" cellspacing="0" cellpadding="0" height="25" width="1000" background="images/menu.jpg">
    <tr>
    <td align="left"style="PADDING-LEFT: 10px"><span class="menu">All Rights Reserved &copy; 2007 - <?php include 'current_yr.php';?> &#174; Registered Trademark.</span></td>
    </tr></table>
</BODY>
</HTML>
Here is the Error:

"Query failed: 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"

All variables are correct and correspond to what is in the Database.
Please show me the Error of my ways!

Thanks in advance,

Batoe

"The road to success is filled with obstacles, but also success!"
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Mysql syntax error; yet again!

Post by fugix »

take out the single quotes around the variables and let me know if you get any more errors
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: Mysql syntax error; yet again!

Post by cap2cap10 »

Removed single quotes but I received the same error. Perplexing

Batoe
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Mysql syntax error; yet again!

Post by fugix »

and you're sure that this

Code: Select all

require_once  'open_db.php';
works?
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: Mysql syntax error; yet again!

Post by cap2cap10 »

Yes, it works with every other php file. I use it throughout the site to access db info.

Perplexing!

Batoe
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Mysql syntax error; yet again!

Post by fugix »

yeah i honestly cant see anything wrong with it...last thing i would say is eliminate the spaces around the = signs
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: Mysql syntax error; yet again!

Post by cap2cap10 »

Thanks all! I found the error. It was concatenation. I turned double quotes into single quotes which solved the problem.

Batoe
Post Reply