Jump to content

Archived

This topic is now archived and is closed to further replies.

morpheus.100

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.

Share this post


Link to post
Share on other sites

must say i think thats a bit complicated to just insert data with an auto-incrementing number appended to a string, could you post a bit more of the code so i can see whats ging on..?

Share this post


Link to post
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());
}

Share this post


Link to post
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...

 

 

Share this post


Link to post
Share on other sites

ok, im spun right out now, i wasnt in the dreamweaver forum, i moved the topic, then an error occurred, showed me that i was in the dreamweaver forum, then posted this post twice. how very strange.

Share this post


Link to post
Share on other sites

×

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.