Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 23rd, 2006, 7:28 AM   #1
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Problem inserting data into database

Hi there ppl.

I am getting an error when i try put data into my database using;

if(isset($_POST['confirm']))
	{
	$subject2 = $_SESSION['subject'];
	$priority2 = $_SESSION['priority'];
	$description2 = $_SESSION['description'];
	$type2 = $_SESSION['type'];
	$time2 = date('l dS \of F Y h:i:s A');
	echo $time2;
	echo"$id";
	$time2="33";
	include '../connect.php';
	$query = "INSERT INTO case VALUES ('','$id','$priority2','$subject2','$description2','$type2','$time2')"; 
	$result = mysql_query($query)or die (mysql_error()."product query"); 
	mysql_close();
I have used similar code before but never had a problem. The error is;

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 'case VALUES ('','30','High','ewrkjh','kjh','Problem','33')' at product query

Any help???
k4pil is offline   Reply With Quote
Old Feb 23rd, 2006, 7:58 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
what is the table description? Are you putting a string into an integer field?
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Feb 23rd, 2006, 9:41 AM   #3
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Ive fixed it.
Case apparently is some keyword in mysql - i used `case` and bingo!
k4pil is offline   Reply With Quote
Old Feb 23rd, 2006, 10:56 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
'Case' is a keyword lots of places (remember switch statements, and even a tractor company I useta know?), best to avoid those types of words and check keyword lists if you think you might need to.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 23rd, 2006, 11:25 AM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Glad you got it worked out... yes, it is a very good idea to check keyword lists when in doubt.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC