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

insert data into database

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 'add que(quedtion_tex)VALUES('')' at line 1

this my code

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>
  4. add question
  5. </title>
  6. <meta name="keywords" content="Web Tech Template, CSS, HTML" />
  7. <meta name="description" content="Web Tech Template is a free CSS website provided by templatemo.com" />
  8. <link href="css/templatemo_style.css" rel="stylesheet" type="text/css" />
  9. <script language="javascript" type="text/javascript">
  10. </script>
  11. </head>
  12. <body>
  13.  
  14.  
  15.  
  16. <?php
  17. error_reporting(0);
  18.  
  19. $quedtion_tex=$_POST['quedtion_tex'];
  20. $con = mysql_connect("localhost","root","");
  21. if (!$con)
  22.   {
  23.   die('Could not connect: ' . mysql_error());
  24.   }
  25.  
  26. mysql_select_db("center_db", $con);
  27.  
  28. $sql="INSERT INTO add que(quedtion_tex)VALUES('$quedtion_tex')";
  29.  
  30. if (!mysql_query($sql,$con))
  31.   {
  32.   die('Error: ' . mysql_error());
  33.   }
  34. echo "1 record added";
  35.  
  36. mysql_close($con)
  37. ?>
  38.  
  39.  
  40.  
  41.  
  42. <form action="add que.php" method="post">
  43. <p>
  44. <input type="text" name="quedtion_tex">
  45. <input type="submit" name="submit"  value="add que" >
  46. </p>
  47.  
  48.  
  49.  
  50. </body>
  51. </html>
May 3 '14 #1
4 1540
Luuk
1,047 Expert 1GB
Why did you not use '[CODE/]' tags around your code?

INSERT INTO add que(quedtion_tex)VALUES.....
is not a valid SQL statement.
What is the name of your database table?
May 3 '14 #2
name of my database table(add que)
May 3 '14 #3
Luuk
1,047 Expert 1GB
You should use backquotes "`" around your tablename, when you decide to use a space in its name....
May 3 '14 #4
koharu
10
Hi Fatma Fares.

Standard MySQL Syntax for an Insert Statement goes as followed;

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO `add que` VALUES ();
For example;
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO `my users` VALUES ('','Koharu',md5('myPass'),'something@towho.com');
I suggest you do some reading on MySQL Queries here;
https://dev.mysql.com/doc/refman/5.0/en/examples.html
May 5 '14 #5

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

Similar topics

2
by: Santo Santis | last post by:
How can I make an .exe file that can insert data automatically in a SQLServer database, I can do it in C, but how can I connect to SQLServer and execute a query. All data that I have to insert...
0
by: Dinu | last post by:
Hi All I am trying to insert data within a transaction, into a Db2 database from asp.net. I have created a System DSN using ISeries Access Driver(32 bit) for Windows. I am then connecting...
1
by: Pratik Gupte | last post by:
I have created a database in .mdf format, but I am unable to insert data into its tables. Can anybody help how to insert data using ASP.Net 2.0 using SQL Server 2005 Express edition in windows...
6
by: VitaminB | last post by:
Hi Guys, I try to insert data from a form into a mysql database, but it did not work... There is no error, but the data did not pass thru the table. This is the short script:
3
by: andrewtayloruk | last post by:
I'm a newbie when it come to things php and i'm having a bit of trouble. I'm trying to insert data from an html form into a mysql database and can't get it to work. Just a few bits about my...
0
by: danishce | last post by:
Hello, I want to insert data directly into my windows form data grid and load a combobox(userid) in the 1st column of data grid,a textbox(password) in 2nd column of datagrid. The code for insert...
1
by: Doc11 | last post by:
I'm trying to allow users insert data into a database using the form view. But when I click the insert button I get this error: Server Error in '/Customer Database' Application....
2
by: Newbie19 | last post by:
I am creating a project that would insert data into a SQL database when the User placed the information into the VB application. Then at a click of a button, it would add this data into the...
8
by: Betikci Boris | last post by:
Can not insert data into SQLite3 database through browser however i can easily insert data into my db from konsole, in both attmpts i used php 5.2.6 on 2.6.25.* linux kernel i think there is a...
0
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume...
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: 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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.