I'm trying to write a couple of values from a search page to a database: but no matter how I tweak the code, I always end up with "Error, insert query failed"...
The code is:
Expand|Select|Wrap|Line Numbers
- <h3><?php echo $_SESSION['SESS_MEMBER_ID']," ",$query; ?></h3>
- <?php
- $link = mysql_connect('localhost','root','EC4SPvRn');
- if(!$link) {
- die('Unable to connect to server: ' . mysql_error());
- }
- //Select database
- $db = mysql_select_db('search_trial');
- if(!$db) {
- die("Unable to select database");
- }
- $sql = "INSERT INTO 'search_records' ('query','user') VALUES ('".$query."','".$_SESSION['SESS_MEMBER_ID']."')";
- mysql_query($sql) or die ('Error, insert query failed');
- ?>
The table name is correct, as are the field names. There is an auto-incrementing ID as the first field in the table.
I assume there is some glaringly simple syntax error here, but I've been staring at it and tweaking it for so long that I just can't see it.