Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with a mysql-query in php 1

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
i have this query:

$query = "INSERT INTO clanwar (name, tag, typ, datum, ergebnis1, ergebnis2) VALUES (\'$HTTP_POST_VARS["name"]\', \'$HTTP_POST_VARS["tag"]\', \'$HTTP_POST_VARS["typ"]\', \'$HTTP_POST_VARS["datum"]\', \'$ergebnis1\', \'$ergebnis2\')";

but on executing it, i get this error-message:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/sites/site05/web/new_clanwar.php on line 19

i think it has got something to do with the ' ' or \ but i can't figure it out... can someone please help me out?


frag patrick.metz@epost.de
 
You could try this
Code:
$query = "INSERT INTO clanwar (name, tag, typ, datum, ergebnis1, ergebnis2) VALUES ("'" . $HTTP_POST_VARS["name"] ."', '" . $HTTP_POST_VARS["tag"] . "', '"  . $HTTP_POST_VARS["typ"] . "', '"  . $HTTP_POST_VARS["datum"] . "', '$ergebnis1', '$ergebnis2')";
This really is just a "cleaner" way to do it. //Daniel
 
hm... i keep getting paring errors...

the tabel has a date field, is there something special i have to think of if i want to insert a date?
is it '2002-08-27' or what?

this drives me wild...


patrick.metz@epost.de
 
Could you post the relevant code? I mean, more than just one line would really make it easier to diagnose what's wrong. //Daniel
 
I infer that your spoken language is German. From that I assume from your variable names that $HTTP_POST_VARS["datum"] contains a date.

Yes, you need to place quotes around a date constant in an SQL statement -- just as you would around a string. ______________________________________________________________________
TANSTAAFL!
 
$query = "INSERT INTO clanwar (name, tag, typ, datum, ergebnis1, ergebnis2) VALUES ('$_POST[name]', '$_POST[tag]', '$_POST[typ]', '$_POST[datum]', '$ergebnis1', '$ergebnis2')";


:) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
daniel's first post actually was the solution!

besides having messed up wiht all the ', \, and " i referenced a wrong field-name too... *blameonme*

thank you very much guys! you help me out... like always [medal]

cu

frag patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top