Jump to content

[SOLVED] Hidden field and Mysql and PHP


ronnie88

Recommended Posts

Here is my form

			<form action="insertsup.php" method="post">
<br><tr><td>UserName:</td><td><input type="text" name="username2" maxlength="25"></td>
<tr><td>Email:</td><td><input type="text" name="email" maxlength="25"></td><br>
<tr><td>Phone:</td><td><input type="text" name="phone" maxlength="25"></td><br>
<tr><td>PayPal Email:</td><td><input type="text" name="paypal" maxlength="25"></td><br>
<input type="hidden" name="order" value="ORDERSUP" />
<tr><td><input name="add" type="submit" id="add" value="Submit and go to billing"></td></form></tr>

and insertsup.php

<?php
session_start();
include 'database.php';
$name = $_POST['username2'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$paypal = $_POST['paypal'];
$order = $_POST['order'];
$characters = $_POST['characters'];
mysql_query("insert into orders(username2, email, phone, paypal, order, size, theme, characters) values('$name', '$email', '$phone', '$paypal', '$order', '', '', '')");
header('Location: http://www.greatdiscountedgames.com/site_flash/ordersent1.html');
?>

 

when i do a mysql error i get this:

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 'order, size, theme, characters) values('Ronnie', '[email protected]', '123456789' at line 1

I know it has something to do with the hidden field.. any help greatly appreciated

 

EDIT: maybe a mysql reserved word?

Link to comment
https://forums.phpfreaks.com/topic/117667-solved-hidden-field-and-mysql-and-php/
Share on other sites

It has nothing to do with the hidden field.  The word "order" is a MySQL reserved word, so change the column name.

 

P.S: You could enclose order in ` `, but it's highly unsuggested because not all database servers accept that as valid SQL so I'd just rename the column.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.