Angeleyezz Posted February 22, 2012 Share Posted February 22, 2012 Anyone have any idea what I did wrong this time? This is def where my problem is // UPDATE THE RECORD WITH THE CURRENT FORM DATA $edit_query_insert="UPDATE client_information SET account_number = '$account_number', name_first = '$name_first', name_last = '$name_last', address = '$address', city = '$city', state = '$state', zipcode = '$zipcode', telephone = '$telephone', telephone_alt = '$telephone_alt', email = '$email'"; This is the code for the page itself: // SELECT THE DATABASE mysql_select_db("terra_elegante_operations", $con); // GET THE FORM DATA FROM PREVIOUS PAGE // ASSIGN NEW VARIABLES $account_number = $_POST['account_number']; $name_first = $_POST['name_first']; $name_last = $_POST['name_last']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zipcode = $_POST['zipcode']; $telephone = $_POST['telephone']; $telephone_alt = $_POST['telephone_alt']; $email = $_POST['email']; // UPDATE THE RECORD WITH THE CURRENT FORM DATA $edit_query_insert="UPDATE client_information SET account_number = '$account_number', name_first = '$name_first', name_last = '$name_last', address = '$address', city = '$city', state = '$state', zipcode = '$zipcode', telephone = '$telephone', telephone_alt = '$telephone_alt', email = '$email'"; if (!mysql_query($edit_query_insert,$con)) { die('Error: ' . mysql_error()); } ?> <table border="0" cellspacing="0" cellpadding="3" width="960" bordercolor="#000000"> <tr> <td valign="top" width="50%"><!-- Open Main left Cell --><table border="0" cellspacing="0" cellpadding="1" width="100%" bordercolor="#000000"><tr><td colspan="4"><B>CLIENT PROFILE</B></td></tr> <?php // Query & assign to the $client_information table. $get_client_information = "SELECT * from client_information where account_number = $account_number"; $client_information = mysql_query($get_client_information) or die (mysql_error()); // The Array & Output - Included HTML Output here for $client_information while ($row = mysql_fetch_array($client_information)) { ?> <tr> <td width="30%"><font face="verdana" size="2" color="#000000">Account Number:</font></td><td colspan="2"><font face="verdana" size="2" color="#000000"><?php echo $row['account_number']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Last Name:</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['name_last']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">First Name:</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['name_first']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Address:</font></td><td><font face="verdana"size="2" color="#000000"><?php echo $row['address']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">City:</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['city']; ?></font></td> </tr> <tr> <td width="10%"><font face="verdana" size="2" color="#000000">State:<font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['state']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Zipcode:</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['zipcode']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Telephone:</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['telephone']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Telephone 2:</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $row['telephone_alt']; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">E-mail</td></td><td><font face="verdana" size="2" color="#000000"><?php echo "<a class=\"bubble_nav\" href='mailto:?id=$row[email]'>$row[email]</a\>"; } ?></font></td> </tr> </table> <?php include('includes/footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/ Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2012 Share Posted February 22, 2012 Are there any errors? What happens, versus what you'd expect to happen? Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320182 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 however the record does put a field in that was null before that i filled in...... doesnt make sense, how is it giving me an error but updating the record anyway. i dont get it Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320185 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 I left something out that I figured but I'm still getting the error // UPDATE THE RECORD WITH THE CURRENT FORM DATA $edit_query_insert="UPDATE client_information SET account_number = '$account_number', name_first = '$name_first', name_last = '$name_last', address = '$address', city = '$city', state = '$state', zipcode = '$zipcode', telephone = '$telephone', telephone_alt = '$telephone_alt', email = '$email' WHERE account_number = $account_number"; forgot the where matchup Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320187 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 Now its not updating at all, it only put the field that was null in, it didnt override it with new data. Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320190 Share on other sites More sharing options...
scootstah Posted February 22, 2012 Share Posted February 22, 2012 What is the output when you echo the query? echo $edit_query_insert; Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320193 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 nothing comes up at all, just that error, Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 no update in the record, no other error message, nothing Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320194 Share on other sites More sharing options...
batwimp Posted February 22, 2012 Share Posted February 22, 2012 You don't have single quotes around your last account number variable like you do in the first part. Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320199 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 I just tried it, i put them in, same thing, took out all the single quotes same thing. nothings changed on it. there has to be something stupid that im doing wrong. Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320202 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2012 Share Posted February 22, 2012 Change your die() to die( "<br>Query string: $edit_query_insert<br>DB Error: " . mysql_error() ); Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320203 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 nothing happened with that, because i dont think the issue was where I thought it was....... seems like the information is updating correctly now, but im still getting that same error message. I think my output is wrong, i just changed it around a bit and here is the new code, still not working correctly. <?php // Query & assign to the $client_information table. $get_client_information = ("SELECT * from client_information WHERE account_number = $account_number") or die(mysql_error()); $client_information = mysql_query($get_client_information) or die (mysql_error()); $new_email = $row['email']; // The Array & Output - Included HTML Output here for $client_information while ($row = mysql_fetch_array($client_information)) { ?> could this be my issue? Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320206 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2012 Share Posted February 22, 2012 Include the line number in the error messages . . . die( "<br>Query string: $edit_query_insert<br>DB Error: " . mysql_error() . "<br>On line# " . __LINE__); Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320209 Share on other sites More sharing options...
Angeleyezz Posted February 22, 2012 Author Share Posted February 22, 2012 Yeah thats definitally the problem somewhere in the query before my loop getting undefined variable : row on line 47, and fetch_array expects parameter 1 to be resource on line 50 Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320210 Share on other sites More sharing options...
darkfreaks Posted February 23, 2012 Share Posted February 23, 2012 after running it through PHP lint it tells me this "required type resource, found type boolean" try this while ($row = mysql_fetch_array($client_information,MYSQL_BOTH)) { Quote Link to comment https://forums.phpfreaks.com/topic/257568-update-record-issue/#findComment-1320275 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.