Jump to content

a quick mydql quesion


corillo181

Recommended Posts

i know i could use the ge tmethod to send into mysql the question is how? i tried my way and it doesn't get me no where.. i dont' know wher eot put the double quote or single.. here is the query

[code]$sql=mysql_query("INSERT INTO guestbook(name, comment, datetime)VALUES($_GET['picname'],'$comment', '$datetime')")or die(mysql_error());[/code]
i put the get method with out any quote so you can tell me in wich way i jhave to put single or double first..

thanx :)

and i know i can do it with variable i just want to know how to do it like that..
Link to comment
Share on other sites

i suggest you do this. it makes all the quotes a bit less confusing. but i strongly advise against inserting a $_GET variable directly into a sql query. you should take $nameofpic and do lots of things with it, like stripslahes/striptags, etc... to prevent sql injection.

$nameofpic = $_GET['picname'];
$sql=mysql_query("INSERT INTO guestbook(name, comment, datetime) VALUES ('$nameofpic','$comment', '$datetime')")or die(mysql_error());
Link to comment
Share on other sites

ok i'll take your wor dfor it.. but i put this a sonly if the sumit bottum is pressed to inser it in to the database but still it get sent into the data bas eeven if is not pressed..

[code]if(isset($_POST['Submit'])){
$sql1=mysql_query("INSERT INTO guestbook(name, comment, datetime)VALUES('$getpic','$comment', '$datetime')")or die(mysql_error());
}
?>[/code]
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.