lxndr Posted November 4, 2007 Share Posted November 4, 2007 I'm sure I must be doing something incredibly dumb here but in certain circumstances when I call this particular php program I have written which is intended to insert a single record I find that instead it inserts the same record twice (there's no index field). I don't know what to make of it, this is the actual code: $today = time(); if (BST()==TRUE) $today = $today + 3600; $sql = "INSERT INTO stories_views VALUES ( '$user_name', $rec_id, $today ) "; $result = mysql_query($sql, $db) or die(" - Failed More Information:<br><pre>$q</pre><br>Error: " . mysql_error()); The field types are as follows: $user_name: varchar $rec_id: int $today: int It's starting to drive me nuts now so if anyone can suggest what the problem might be it'd be much appreciated. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 4, 2007 Share Posted November 4, 2007 Hmmm...I don't see anything wrong with that chunk of code. You should wrap your variables in quotes within queries. $sql = "INSERT INTO stories_views VALUES ( '$user_name', '$rec_id', '$today') "; Is that all the code from that file? If not, could you post more of it? Quote Link to comment Share on other sites More sharing options...
kratsg Posted November 4, 2007 Share Posted November 4, 2007 I can't see the code that well, stick it in between some [ code ] [ /code ] stuff. However, as the recent reply says, try something like this: $sql = "INSERT INTO stories_views (username,rec_id,today) VALUES ( '$user_name', '$rec_id', '$today') "; Where username, rec_id, and today are the corresponding columns you want to add in. It may be something technical and picky o_o Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.