473,386 Members | 1,763 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,386 software developers and data experts.

INSERT into table ? problem

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dbhost    ="";
  3. $dbuser    ="";
  4. $dbpass    ="";
  5. $dbname    ="school";
  6. $db_table = "student"; 
  7.  
  8. $connection=@mysql_connect($dbhost,$dbuser,$dbpass);
  9.     if (!$connection) die ("Mysql connection error" .mysql_error());
  10.     error_reporting(E_ERROR | E_WARNING | E_PARSE);
  11. mysql_select_db($dbname,$connection) or die ("Database connection error");
  12. $query="INSERT INTO $db_table( ID, Name , Surname, Last Name, EGN, Course, Address)
  13. VALUES
  14. ('NULL','{$_POST['Name']}','{$_POST['Surname']}','{$_POST['Last Name']}','{$_POST['EGN']}','{$_POST['Course']}','{$_POST['Address']}')";
  15. if (!mysql_query($query,$connection))
  16.   {
  17.   die('Error: ' . mysql_error());
  18.   }
  19. echo "1 record added";
  20.  
  21. mysql_close($connection);
  22. ?> 

I don't understand what's the problem

Error: 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 'Name, EGN, Course, Address) VALUES ('NULL','','','','','','')' at line 1
Apr 1 '12 #1
3 1654
Rabbit
12,516 Expert Mod 8TB
Name is a reserved key word in SQL, you should rename the column.
Apr 1 '12 #2
Dormilich
8,658 Expert Mod 8TB
and column names should not have spaces either.
Apr 2 '12 #3
thanks :))
I corrected it
Apr 2 '12 #4

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

Similar topics

2
by: Savas Ates | last post by:
i have a stored below it uses create temp table and drop temp table... when more than one user request the same page it probably returns error.. how can i solve this problem ...
6
by: Murtix Van Basten | last post by:
HI all, I am trying to migrate a database from mysql to mssql2k. I use myODBC to connect to mysql server to pull the database from DTS and insert in to sql server. But in mysql server, there is...
7
by: David Findlay | last post by:
I'm trying to do a table for laying out a links page in CSS. See http://qldstorms.com/links.php. My stylesheet is at http://qldstorms.com/styles/screen.css. My problem is that if the link name in...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
1
by: erikcw | last post by:
Hi, I'm trying to insert some data from an XML file into MySQL. However, while importing one of the files, I got this error: Traceback (most recent call last): File "wa.py", line 304, in ?...
1
by: quartz | last post by:
Hello, I have a txt file with names, years, days. How can I insert table using shell scripting??? Thenks a lot,
10
by: Steve Kelley | last post by:
Hello all. I'm new to this group and I'm working on my first real VB.Net project. I'm having trouble creating and archive of a database. We use an Access database to store results from our...
0
by: tvnaidu | last post by:
database file gets created using below sql file, then lua script calls "db.import config_ascc", then I get errors says "insert table failed for eventLog", below are my sql file entry, config file,...
3
by: josephamarks | last post by:
I am trying to correct a table problem. In IE6, the table (created in VS with ASPX) does display correctly. Ijn IE8, it adds unwanted horizontal scrollbars, and the columns do not display...
0
by: sprofis | last post by:
when executing an insert query in java it is not updating the table with the new values. i've noticed that the problem occurs when the tables contain key/keys. it shows that the query was executed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.