| | |
what is wrong with this code?
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
i get this 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 'index, user_id, username, message) VALUES(' ', '4', 'zack', 'jh')' at line 1
MySQL Syntax (Toggle Plain Text)
<?php session_start(); $_SESSION['user_id'] = 4; $user_id = $_SESSION['user_id']; $_SESSION['username'] = "zack"; $username = $_SESSION['username']; $message = $_POST['shout_mes']; $insert = $_POST['shout']; if(!empty($message) && $insert = "shout"){ include('mysqlcon.php'); $select = mysql_select_db($db, $con); if(!$select){ die('could not select db: ' . mysql_error()); } $sql = mysql_query("INSERT INTO shoutbox (index, user_id, username, message) VALUES(' ', '$user_id', '$username', '$message')"); if(!$sql){ echo "error" . mysql_error(); }ELSE{ header("location: index.php"); } }ELSE{ echo "there was an error: " . mysql_error(); } ?>
ok here is what worked.
MySQL Syntax (Toggle Plain Text)
$sql = mysql_query("INSERT INTO shoutbox (user_id, username, message) VALUES('$user_id', '$username', '$message')");
![]() |
Similar Threads
- im not quite sure what's wrong with my code. (Java)
- I cant find what is wrong in this code (C++)
- Please help me i dont understand whats wrong with my code (C++)
- what's wrong in this code? (PHP)
- What's wrong with this code? (C#)
- What is wrong with this code? (C++)
- What is wrong with this code??? (Visual Basic 4 / 5 / 6)
- Whats wrong with this code (PHP)
- Something wrong with my code, why Junk character appears? (C)
Other Threads in the MySQL Forum
- Previous Thread: Protecting against sql injections
- Next Thread: Trying to find character occurrences in table field using SUM???
| Thread Tools | Search this Thread |
agplv3 amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





