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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building a SQL string with PHP

Status
Not open for further replies.

jokobe

Programmer
May 7, 2003
6
DE
Well,
I tried to build a sql string with PHP.
When echoed it looks like that:
Insert into personal ( f_name, s_name, genus, kita_function, kita_group, start_date) values( '$f_name', '$s_name', '$genus', '$kita_function', '$kita_group', '$start_date')

In the fields like $f_name values are stored from a HTML form and they should be inserted into the table PERSONAL. Instead,
the value $f_name is inserted.
If I echo $f_name the proper value is shown in the browser.
Any helpful hint???

jokobe
 
Paste the actual php line into here where you build the sql string. You're probably quoting wrong, or you may have "magic quotes" turned on, which is evil and can cause a lot of problems like this.
 
Personally, i would use the following:
Code:
$sql = "
INSERT INTO personal 
       (f_name, 
        s_name, 
        genus, 
        kita_function, 
        kita_group, 
        start_date) 
VALUES
     ( '".$f_name."', 
       '".$s_name."',
       '".$genus."', 
       '".$kita_function."',
       '".$kita_group."',
       '".$start_date."')
";

HTH

CAFF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top