morpheus.100 Posted July 20, 2004 Share Posted July 20, 2004 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. Quote Link to comment https://forums.phpfreaks.com/topic/1899-parse-errors-in-insert-loop/ Share on other sites More sharing options...
theverychap Posted July 20, 2004 Share Posted July 20, 2004 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..? Quote Link to comment https://forums.phpfreaks.com/topic/1899-parse-errors-in-insert-loop/#findComment-6179 Share on other sites More sharing options...
morpheus.100 Posted July 20, 2004 Author Share Posted July 20, 2004 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()); } Quote Link to comment https://forums.phpfreaks.com/topic/1899-parse-errors-in-insert-loop/#findComment-6180 Share on other sites More sharing options...
theverychap Posted July 20, 2004 Share Posted July 20, 2004 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... Quote Link to comment https://forums.phpfreaks.com/topic/1899-parse-errors-in-insert-loop/#findComment-6181 Share on other sites More sharing options...
theverychap Posted July 20, 2004 Share Posted July 20, 2004 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. Quote Link to comment https://forums.phpfreaks.com/topic/1899-parse-errors-in-insert-loop/#findComment-6182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.