473,508 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why can't I add data into the table?

1 New Member
How can I fix this?


This is the warning:

Expand|Select|Wrap|Line Numbers
  1. Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\pos\addmessage.php  on line 4
  2.  

This is the code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_connect("localhost","root","");
  3. @mysql_select_db("pointofsales") or die ("Unable to connect");;
  4. $sql=mysql_query("INSERT INTO products(prodid, prodname, description, amount, stocks)VALUES('$_POST[ProdID]','$_POST[ProdName]','$_POST[Description]','$_POST[Amount]','$_POST[Stocks]')";
  5. mysql_query($sql);
  6. mysql_close();
  7. echo "Record is added successfully";
  8. ?>
  9.  
I'm a beginner. I would appreciate your help. Thanks!
Mar 7 '11 #1
2 1606
Mayur2007
67 New Member
Hello,

Try the below code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     mysql_connect("localhost","root","");
  3.     @mysql_select_db("pointofsales") or die ("Unable to connect");;
  4.     $sql = "INSERT INTO products(prodid, prodname, description, amount, stocks)
  5.                             VALUES ('".$_POST[ProdID]."',
  6.                                     '".$_POST[ProdName]."',
  7.                                     '".$_POST[Description]."',
  8.                                     '".$_POST[Amount]."',
  9.                                     '".$_POST[Stocks]."');";
  10.     $sql=mysql_query($sql);
  11.     if(mysql_query($sql)) {    
  12.         echo "Record is added successfully";
  13.     } else {
  14.         echo "There is some error";
  15.     }
  16.     mysql_close();
  17. ?>
  18.  
Mar 7 '11 #2
MrMancunian
569 Recognized Expert Contributor
Look at line 3, there's a double semicolon... The error tells you it's row 4 and most of the times, the error is one row earlier.

Steven
Mar 7 '11 #3

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

Similar topics

1
108820
by: lawrence | last post by:
I just switched error_reporting to ALL so I could debug my site. I got a huge page full of errors. One of the most common was that in my arrays I'm using undefined offsets and indexes. These still...
5
10865
by: news.bigpond.com | last post by:
getting errors Notice: Undefined index: name in F:\uni\Software engineering\assignment4\guestbook.php on line 6 the variable $name is declared as $name = _POST; What could be causing this?...
4
7173
by: John Oliver | last post by:
PHP Notice: Undefined index: name in /home/www/reformcagunlaws.com/new.php on line 6 PHP Notice: Undefined index: address in /home/www/reformcagunlaws.com/new.php on line 7 PHP Notice: ...
3
4956
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined...
3
5483
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice:...
15
4450
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
5
7168
by: siyaverma | last post by:
Hi, I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that, After doing some changes when i run it on my...
3
3848
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if...
3
5975
by: razvanel442 | last post by:
Hi all i am new here! I take a look on forum but i don't found a the answer for my problem ok this is my problem: Line47:$user = $_GET; Line48:$pass = $_GET; Line49:$char = $_GET;
3
2014
by: mediator | last post by:
Hello I have a php contact email form on my a ecommerce shop website ! I am getting a Undefined index error messages coming from the top of the php code, the email form its self works fine, ...
0
7224
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
7118
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
7323
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
7379
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
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.