Jump to content


Dynamic Insert into SQL

  • Please log in to reply
1 reply to this topic

#1 dalton6275

  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 11 April 2006 - 02:54 PM

I have an 'insert into database' code which i am trying to make the table the information is inserted to dependant on a URL variable i am carrying across from the previous page.

My code is
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO %s (Monthref, percentage) VALUES (%s, %s)", 
                       GetSQLValueString($_POST['sla'], "text"),
                       GetSQLValueString($_POST['month'], "date"),
                       GetSQLValueString($_POST['slapercent'], "int"));
but it is not liking the 1st %s code in the 'INSERT INTO %s'

Anyone know how i can remedy this???

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 11 April 2006 - 08:47 PM

What does $_POST['sla'] contain?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users