473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

php mysql WHERE clause Syntax error

Hi, iam trying to insert values in the child table, with condition that both pk and fk should match,
pk = stud_id and fk dstud_id.
here is what iam trying
Expand|Select|Wrap|Line Numbers
  1. include('config.php'); 
  2. if (isset($_GET['stud_id']) ) { 
  3. $id = (int) $_GET['stud_id']; 
  4. if (isset($_POST['submitted'])) { 
  5.  
  6. foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } 
  7.  
  8. $sql = "INSERT INTO `cjet`.`student_don_reg_history` (`stud_full_name`,`course_place`,`course_year`,
  9. `course_name`,`stud_reg_no`,`don_amt`,`dd_no`) 
  10. VALUES('{$_POST['stud_full_name']}','{$_POST['place']}',
  11. '{$_POST['year']}','{$_POST['course']}','{$_POST['stud_reg']}',
  12. '{$_POST['don_amt']}','{$_POST['dd_no']}')WHERE `dstud_id` = '$id' ";
  13.  
  14. mysql_query($sql) or die(mysql_error());
  15.  
Oct 6 '10 #1
3 2238
Markus
6,050 Expert 4TB
INSERTs do not have a WHERE clause.
Oct 6 '10 #2
kovik
1,044 Expert 1GB
If the ID is already known but you aren't sure if the record exists, you may wish to use REPLACE INTO instead of INSERT INTO.
Oct 6 '10 #3
Many Thanks Markus, your comment just ended an hour of mepulling my hair out! :)
Nov 14 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Julien - Marseille | last post by:
Hello, I need help for php syntax when i call Mysql database I have wrote that and my sql connection is working I just have a problem with this command line : $query = "SELECT * FROM...
1
by: Maciej Paras | last post by:
Hello! I've written 2 pages: one i HTML format, and second - in ASP. When I'm posting data from HTML page, I receive this error generated by ASP page: Microsoft JET Database Engine (0x80040E14)...
0
by: Jonas Gorauskas | last post by:
I am having this one problem on an app I am writing where it shows the following error on some error trapping that I did: Query failed: Error Number: 1064 Description: You have an error in...
2
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
4
by: James | last post by:
Please help me with this sql: SELECT z005aNORTHEAST_3days_Formula.Region, z005aNORTHEAST_3days_Formula.DiffofClaimsAssignment FROM (SELECT .Region, (.)-( .) AS DiffofClaimsAssignment FROM...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
11
by: Frankie | last post by:
Hello: New user here...first post to group. I'm getting an SQL syntax error when I try to run the following query: $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
1
by: darrel | last post by:
hi there can anyone tell me wats wrong with my program, its a like this i have a database called "dbTimescheduling", with a field with a name of "Time",,, for now i want to do is to be able to access...
7
by: ajos | last post by:
hi friends, i have a problem in mysql query..when i click on submit the values get enterred but i get a ever since i did some changes in my code(earlier i was getting a null pointer...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.