hey_suburbia Posted August 9, 2006 Share Posted August 9, 2006 This give me a nice read out:[code] echo ("INSERT INTO counter (email,name,pagename,date)". "VALUES ('$sess', '$sess2', '$scr2', ".date('l dS \of F Y h:i:s A').")");[/code]but this won't go into my DB:[code] $result = mysql_query("INSERT INTO counter (email,name,pagename,date)". "VALUES ('$sess', '$sess2', '$scr2', ".date('l dS \of F Y h:i:s A').")");[/code]Any thoughts? It's connecting because if I try just this:[code] $result = mysql_query("INSERT INTO counter (email)". "VALUES ('$sess')");[/code]It gives me a new field but they are blank... Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 9, 2006 Share Posted August 9, 2006 [code]<?phpmysql_query("INSERT INTO counter (email,name,pagename,date)". "VALUES ('$sess', '$sess2', '$scr2', ".date('l dS \of F Y h:i:s A').")");?>[/code]try that by itself. It's not going to INSERT, if you don't tell it to. If your simply saying $result = [query], you're not telling it to execute it. Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 9, 2006 Share Posted August 9, 2006 Where are you defining: $sess, $sess2, $scr2? Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted August 9, 2006 Author Share Posted August 9, 2006 @CesearI am passing these variables:[code]$sess=$_SESSION['email'] ;$sess2=$_SESSION['visitor'] ;$scr=$_SERVER['SCRIPT_FILENAME'];[/code]I have it working now, up to the date, so I'm thinking the date syntax is wrong? Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 9, 2006 Share Posted August 9, 2006 run the query lilke this$query = "INSERT INTO counter (email,name,pagename,date)". "VALUES ('$sess', '$sess2', '$scr2', '".date('l dS \of F Y h:i:s A')."'";$result = mysql_query($query);if($result){echo everything worked}else{echo "Error: ".mysql_error();}I also noticed date did not have single quotes round it Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted August 9, 2006 Author Share Posted August 9, 2006 Thanks!I got it working by just putting the date into a variable:[code]$thedate=date('l dS \of F Y h:i:s A');$result = mysql_query("INSERT INTO counter (email,name,pagename,date)"."VALUES ('$sess', '$sess2', '$scr2', '$thedate')");[/code] Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 9, 2006 Share Posted August 9, 2006 you were missing the single quotesIts easier to read the query if you only use variables and strings (no funcitons) 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.