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();} Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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]? Quote Link to comment 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 Quote Link to comment 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.