Dynadot โ€” .com Transfer

50np$ for simple php question.

NamecheapNamecheap
Watch

QBert

Established Member
Impact
10
$sql = "INSERT INTO blog_msg (msg) VALUES ('$msg)";

that adds a form called msg into a feild called msg, now if i had more form feilds to be entered into more database feilds how would i do it?
i expect it to be somthing like

$sql = "INSERT INTO blog_msg (msg, name) VALUES ('$msg name)";

or

$sql = "INSERT INTO blog_msg (msg, name) VALUES ('$msg, name)";

or somthing simple. i had it working once a long time ago, now trying to recerate :)

Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Don't you need quotes around the individual values?

Lets say I wanted to insert name and adress it would be like:

PHP:
INSERT INTO Persons (LastName, Address) VALUES ('value2', 'value1')

So for you it would be something like:

PHP:
$sql = "INSERT INTO blog_msg (msg, name) VALUES ('$msg', 'name')";

Might want to define name as a variable.
 
Last edited:
0
•••
Nunim said:
PHP:
$sql = "INSERT INTO blog_msg (msg, name) VALUES ('$msg', 'name')";

it will work better if you do it as :-

$sql = "INSERT INTO blog_msg (msg, name) VALUES ('".$msg."', 'name')";

a variable can't be in single qutation marks (otherwise it wont process the variable). Concatenation get's around this otherwise you could have escaped the single qutation marks
 
0
•••
50np$ sent to the 2 people that replyed. i got my awnser :)

QBert
 
0
•••
my bad wasn't paying attention, and was in a hurry to get 50 np$ :O
 
0
•••
:o I need some NP$!!

i need to hurry up :)
 
0
•••
lol you are only 28 days late not too bad.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back