Jump to content

Parse errors in insert loop.


Recommended Posts

Hi all

I have created an insert loop to increment fieldname by count. $x will define the loop number so I wish to display 'track_name' as ' track_name1', 'track_name2' etc on each cycle of the loop. Trying to parse the $x to the track_name always seems to return a parse error. If anyone can shed some light on how to achieve this I would be grateful.

 

$insertSQL = sprintf("INSERT INTO metal_tracks (disco_id, track_name, comments) VALUES (%s, %s, %s)", 
                        
         GetSQLValueString($_POST['disco_id'], "int"), 
         GetSQLValueString($_POST['track_name'], "text"), 
         GetSQLValueString($_POST['comment'], "text")); 

 

 

Thanks in advance for any suggestions.

Link to comment
Share on other sites

Heres the full loop and they arent auto incrementing. Disco id is the auto increment field. Its value remains the same in all entries from an echo session. The other 2 fields are to be inserted from a fully dynamic form that could have upto 40 entries. The for is also built from a loop based on a form variable so I need to reverse the loop to insert the fields.

 

Thanks again.

 

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
//conditional loop
if (isset($_POST['send'])) 
{ 
$send = $_POST['send']; 
} 
else 
{ 
exit(); 
}  
for ($x = 1; $x <= $send; $x++) 
{

 $insertSQL = sprintf("INSERT INTO metal_tracks (disco_id, track_name, comments) VALUES (%s, %s, %s)",
     
                      GetSQLValueString($_POST['disco_id'], "int"),
                      GetSQLValueString($_POST['track_name'], "text"),
                      GetSQLValueString($_POST['comment'], "text"));
      

 mysql_select_db($database_SiteConn, $SiteConn);
 $Result1 = mysql_query($insertSQL, $SiteConn) or die(mysql_error());
}

Link to comment
Share on other sites

unfortunately i'm not au-faix with dreamweavers way of outputting php, so unfortunately i wont be able to really help.

 

just for the record, i used to use dreamweaver a long time ago (before php support) and quickly got tired of its rewriting of my code, so i knocked it on the head)

 

sorry about that.

 

im going to move this topic to the Dreamweaver forum...

 

 

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.