Jump to content

echo works, but doesn't write to DB


hey_suburbia

Recommended Posts

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...
Link to comment
Share on other sites

[code]<?php
mysql_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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.