DBookatay Posted March 19, 2007 Share Posted March 19, 2007 Hi Freaks! I have a page with (technically) 3 forms on the same page, I say technically because of which "forms_view.php?body=________" you are on determines which form you are actually seeing. For some reason I can only get 2 out of the 3 post querys to function, and I've tried EVERYTHING... Moving the order of them around, moving them to different locations on the page, renaming the querys, everything, still the last one (query3) will not work... Can anyone spot the error? if (isset($_POST['edit'])){ $query = "UPDATE EZFinancing_Apps SET status = '{$_POST['status']}', apScore = '{$_POST['apScore']}', coapScore = '{$_POST['coapScore']}', Citi = '{$_POST['Citi']}', AL = '{$_POST['AL']}', UCF = '{$_POST['UCF']}' where id = '$id'"; if ($result = mysql_query ($query)) {header('Location: forms_view.php?id=' . $id );} if ($_POST['cmnts']){ $post_comments = addslashes(escape_data($_POST['cmnts'])); $query2 = "INSERT INTO EZFinancing_Notes SET App_id = '$id', comments = '$post_comments', posted = NOW()"; } if ($result = mysql_query ($query2)) {header('Location: forms_view.php?id='.$id.'&body=Notes');} if ($_POST['vehYear']){ $query3 = "INSERT INTO EZFinancing_Figures SET App_id = '$id', year = '{$_POST['year']}', make = '{$_POST['make']}', model = '{$_POST['model']}', A = '{$_POST['A']}', B = '{$_POST['B']}', C = '{$_POST['C']}', D = '{$_POST['D']}', E = '{$_POST['E']}', F = '{$_POST['F']}', G = '{$_POST['G']}', H = '{$_POST['H']}', I = '{$_POST['I']}', J = '{$_POST['J']}', K = '{$_POST['K']}', L = '{$_POST['L']}', M = '{$_POST['M']}', O = '{$_POST['O']}', 1 = '{$_POST['1']}', 2 = '{$_POST['2']}', amtFin = '{$_POST['amtFin']}', finChrg = '{$_POST['finChrg']}', totalPymts = '{$_POST['totalPymts']}', totalPrce = '{$_POST['totalPrce']}', finRsrve = '{$_POST['finRsrve']}', price = '{$_POST['price']}', weekly = '{$_POST['weekly']}', monthly = '{$_POST['monthly']}'"; } if ($result = mysql_query ($query3)) {header('Location: forms_view.php?id='.$id.'&body=Notes');} else {echo mysql_error();} Link to comment https://forums.phpfreaks.com/topic/43410-can-anyone-spot-the-error/ Share on other sites More sharing options...
papaface Posted March 19, 2007 Share Posted March 19, 2007 Your insert SQL is incorrect. It should follow this template: $query3 = "insert into EZFinancing_Figures (App_id,year,make,model) values ('{$id}','{$_POST['year']}','{$_POST['make']}','{$_POST['model']}')"; etc Also you should mysql_real_escape_string() all $_POST vars before putting them in the db. Link to comment https://forums.phpfreaks.com/topic/43410-can-anyone-spot-the-error/#findComment-210843 Share on other sites More sharing options...
DBookatay Posted March 20, 2007 Author Share Posted March 20, 2007 Also you should mysql_real_escape_string() all $_POST vars before putting them in the db. Can you please explain, or show me an example, I do not know what that means? BTW: Thank you, your code solved my problem... Should I rewrite the 2 other querys (or is it "queries,") the same way? Link to comment https://forums.phpfreaks.com/topic/43410-can-anyone-spot-the-error/#findComment-210848 Share on other sites More sharing options...
suzzane2020 Posted March 20, 2007 Share Posted March 20, 2007 cu u try removing the single qoutes from $_POST[1] and $_POST[2]? Link to comment https://forums.phpfreaks.com/topic/43410-can-anyone-spot-the-error/#findComment-210849 Share on other sites More sharing options...
Barand Posted March 20, 2007 Share Posted March 20, 2007 @papaface While I agree the "INSERT INTO table (...) VALUES (...)" syntax is more portable, the "INSERT INTO table SET ..." is valid MySQL syntax. See second syntax oprion at http://dev.mysql.com/doc/refman/4.1/en/insert.html Link to comment https://forums.phpfreaks.com/topic/43410-can-anyone-spot-the-error/#findComment-210857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.