Bl4ckMaj1k Posted March 31, 2011 Share Posted March 31, 2011 <?php session_start(); $successMsg = ''; $staff_id = $_SESSION['sid']; include_once "scripts/connect_to_mysql.php"; $customer_id = $_GET['cid']; $customer_id = mysql_real_escape_string($customer_id ); $customer_id = eregi_replace("`", "", $customer_id); $cust_project_id = $_GET['pid']; $cust_project_id = mysql_real_escape_string($cust_project_id ); $cust_project_id = eregi_replace("`", "", $cust_project_id); if (isset($_POST['billing_contact_fax_form_field_box'])){ $billing_contact_fname_form_field_box = $_POST['billing_contact_fname_form_field_box']; $billing_contact_lname_form_field_box = $_POST['billing_contact_lname_form_field_box']; $billing_contact_address_form_field_box = $_POST['billing_contact_address_form_field_box']; $billing_contact_city_form_field_box = $_POST['billing_contact_city_form_field_box']; $billing_contact_state_form_field_box = $_POST['billing_contact_state_form_field_box']; $billing_contact_zip_form_field_box = $_POST['billing_contact_zip_form_field_box']; $billing_contact_email_form_field_box = $_POST['billing_contact_email_form_field_box']; $billing_contact_phone_form_field_box = $_POST['billing_contact_phone_form_field_box']; $billing_contact_fax_form_field_box = $_POST['billing_contact_fax_form_field_box']; $billing_contact_pref_meth_contact_form_field_box = $_POST['billing_contact_pref_meth_contact_form_field_box']; $billing_contact_cc_billed_form_field_box = $_POST['billing_contact_cc_billed_form_field_box']; $sql = mysql_query("UPDATE billing_info SET contact_fname='$billing_contact_fname_form_field_box',contact_lame='$billing_contact_lname_form_field_box',address='$billing_contact_address_form_field_box',city='$billing_contact_city_form_field_box',state='$billing_contact_state_form_field_box',zip='$billing_contact_zip_form_field_box',email='$billing_contact_email_form_field_box',phone='$billing_contact_phone_form_field_box',fax='$billing_contact_fax_form_field_box',pref_meth_contact='$billing_contact_pref_meth_contact_form_field_box',cc_billed='$billing_contact_cc_billed_form_field_box' WHERE proj_id='$cust_project_id'"); $successMsg = '<p style="font-family:Myriad Web Pro" style="font-size:10px" style="color:#666">You have successfully updated the company\'s General Information.<br /><br /> <a href="javascript:window.close();">Close</a></p>'; echo $successMsg; exit(); } ?> I have played around with this for SOOOOO long. I have 2 other scripts that are almost exact replicas of this script. Only difference is they are communicating with a different table...but its basically the EXACT same structure of code and functions. My tables consist of some int values, some varchar values, and the data submitted in these variables should get written to the table where the project ID is = to the id I'm working with. All of that seems to be working fine but whenever I enter the info into the form and submit, NOTHING gets written to my table....I'm completely STUMPED and P-O'd that I just wasted a complete 2 hours doing guess and check and cross comparing scripts. I can't find a thing!!!! Below is my html.....hopefully someone smarter than me can put 2 and 2 together because obviously I am an idiot!!!! Also its organized so well that you would think diagnosing the issue would be simple....not the case. I am totally and utterly stumped. I will even add my other code that works to show you what I mean. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.form.billing_contact_fname_form_field_box.value == "" ) { alert ( "Please fill out the First Name field." ); valid = false; } if ( document.form.billing_contact_lname_form_field_box.value == "" ) { alert ( "Please fill out the Last Name field." ); valid = false; } if ( document.form.billing_contact_address_form_field_box.value == "" ) { alert ( "Please fill out the Address field." ); valid = false; } if ( document.form.billing_contact_city_form_field_box.value == "" ) { alert ( "Please fill out the City field." ); valid = false; } if ( document.form.billing_contact_state_form_field_box.value == "" ) { alert ( "Please fill out the State field." ); valid = false; } if ( document.form.billing_contact_zip_form_field_box.value == "" ) { alert ( "Please fill out the Zip field." ); valid = false; } if ( document.form.billing_contact_email_form_field_box.value == "" ) { alert ( "Please fill out the Email field." ); valid = false; } if ( document.form.billing_contact_phone_form_field_box.value == "" ) { alert ( "Please fill out the Phone field." ); valid = false; } if ( document.form.billing_contact_fax_form_field_box.value == "" ) { alert ( "Please fill out the Fax field." ); valid = false; } return valid; } <!-- Form Validation --> </script> </head> <body> <div id="pg_container"> <!--PAGE CONTAINER--> <div id="pgbdy_container"> <div id="pgbdy"> <div id="bdy_header"></div> <div id="bdy_content_area"> <div id="bdy_content_general_info"> <div id="bdy_form_header"> <p> Please complete the Billing Information form below.<br /> <i>Fields marked with a</i> <b>*</b> <i>are required fields.</i> </p> </div> <form action="" method="post" enctype="multipart/form-data" id="form" name="form" onsubmit="return validate_form ( );"> <!--BILLING CONTACT FIRST NAME--> <div id="billing_contact_fname_form"> <div id="billing_contact_fname_form_text"> <p>*First Name:</p> </div> <div id="billing_contact_fname_form_field"> <input name="billing_contact_fname_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT FIRST NAME--> <!--BILLING CONTACT LAST NAME--> <div id="billing_contact_lname_form"> <div id="billing_contact_lname_form_text"> <p>*Last Name:</p> </div> <div id="billing_contact_lname_form_field"> <input name="billing_contact_lname_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT LAST NAME--> <!--BILLING CONTACT ADDRESS NAME--> <div id="billing_contact_address_form"> <div id="billing_contact_address_form_text"> <p>*Address:</p> </div> <div id="billing_contact_address_form_field"> <input name="billing_contact_address_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT ADDRESS NAME--> <!--BILLING CONTACT CITY NAME--> <div id="billing_contact_city_form"> <div id="billing_contact_city_form_text"> <p>*City:</p> </div> <div id="billing_contact_city_form_field"> <input name="billing_contact_city_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT CITY NAME--> <!--BILLING CONTACT STATE NAME--> <div id="billing_contact_state_form"> <div id="billing_contact_state_form_text"> <p>*State:</p> </div> <div id="billing_contact_state_form_field"> <input name="billing_contact_state_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT STATE NAME--> <!--BILLING CONTACT ZIP NAME--> <div id="billing_contact_zip_form"> <div id="billing_contact_zip_form_text"> <p>*Zip:</p> </div> <div id="billing_contact_zip_form_field"> <input name="billing_contact_zip_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT ZIP NAME--> <!--BILLING CONTACT EMAIL NAME--> <div id="billing_contact_email_form"> <div id="billing_contact_email_form_text"> <p>*Email:</p> </div> <div id="billing_contact_email_form_field"> <input name="billing_contact_email_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT EMAIL NAME--> <!--BILLING CONTACT PHONE NAME--> <div id="billing_contact_phone_form"> <div id="billing_contact_phone_form_text"> <p>*Phone:</p> </div> <div id="billing_contact_phone_form_field"> <input name="billing_contact_phone_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT PHONE NAME--> <!--BILLING CONTACT FAX NAME--> <div id="billing_contact_fax_form"> <div id="billing_contact_fax_form_text"> <p>Fax:</p> </div> <div id="billing_contact_fax_form_field"> <input name="billing_contact_fax_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT FAX NAME--> <!--BILLING CONTACT PREFERRED METHOD OF CONTACT NAME--> <div id="billing_contact_pref_meth_contact_form"> <div id="billing_contact_pref_meth_contact_form_text"> <p>*Preferred Method of Contact:</p> </div> <div id="billing_contact_pref_meth_contact_form_field"> <select name="billing_contact_pref_meth_contact_form_field_box"> <option value="Email">Email</option> <option value="Phone">Phone</option> <option value="Fax">Fax</option> <option value="">Physical Mail</option> </select> </div> </div> <!--BILLING CONTACT PREFERRED METHOD OF CONTACT NAME--> <!--BILLING CONTACT CREDIT CARD OR BILLED NAME--> <div id="billing_contact_cc_billed_form"> <div id="billing_contact_cc_billed_form_text"> <p>*Will the customer pay with Credit Card or will they be billed (Credit must be approved before ordering)?</p> </div> <div id="billing_contact_cc_billed_form_field"> <select name="billing_contact_cc_billed_form_field_box"> <option value="Credit Card">Credit Card</option> <option value="Billed">Billed</option> </select> </div> </div> <!--BILLING CONTACT CREDIT CARD OR BILLED NAME--> <!-- SUBMIT BUTTON --> <div id="submit_billing_info"> <input name="submit_billing_info" type="submit" /> </div> <!-- SUBMIT BUTTON --> </form> </div> </div> </div> </div> <!--PAGE CONTAINER--> </div> </body> </html> Now here is the code that works in its entirety....please note that the above is broken up just as it would be seen on the page. PHP at the top and then the HTML. It mimics the script I am about to paste below. Please help meeeeeeee!!!! <?php session_start(); $successMsg = ''; $staff_id = $_SESSION['sid']; include_once "scripts/connect_to_mysql.php"; $customer_id = $_GET['cid']; $customer_id = mysql_real_escape_string($customer_id ); $customer_id = eregi_replace("`", "", $customer_id); $cust_project_id = $_GET['pid']; $cust_project_id = mysql_real_escape_string($cust_project_id ); $cust_project_id = eregi_replace("`", "", $cust_project_id); if (isset($_POST['company_name'])){ $company_name = ereg_replace("[[^A-Z a-z0-9]]", "", $_POST['company_name']); // filter everything but numbers and letters $customer_fname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_fname']); // filter everything but spaces, numbers, and letters $customer_lname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_lname']); // filter everything but spaces, numbers, and letters $customer_address = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_address']); // filter everything but spaces, numbers, and letters $customer_city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_city']); // filter everything but numbers and letters $customer_state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_state']); // filter everything but numbers and letters $customer_zip = ereg_replace("[^A-Za-z0-9]", "", $_POST['customer_zip']); // filter everything but numbers and letters $customer_email = stripslashes($_POST['customer_email']); $customer_email = strip_tags($customer_email); $customer_email = mysql_real_escape_string($customer_email); $customer_phone = ereg_replace("[^A-Za-z0-9]", "", $_POST['customer_phone']); // filter everything but spaces, numbers, and letters $customer_fax = ereg_replace("[^A-Za-z0-9]", "", $_POST['customer_fax']); // filter everything but spaces, numbers, and letters $cust_pre_meth_contact = $_POST['cust_pre_meth_contact']; // filter everything but spaces, numbers, and letters $date_of_entry = date("F j, Y, g:i a"); $sql = mysql_query("UPDATE company_info SET company_name='$company_name',contact_fname='$customer_fname',contact_lname='$customer_lname', address='$customer_address', city='$customer_city', state='$customer_state', zip='$customer_zip', email='$customer_email', phone='$customer_phone', fax='$customer_fax',pref_meth_contact='$cust_pre_meth_contact',entry_date='$date_of_entry' WHERE proj_id='$cust_project_id'"); $successMsg = '<p style="font-family:Myriad Web Pro" style="font-size:13px" style="color:#666">You have successfully updated <b>' . $company_name . '\'s</a></b> Company Information.<br /><br /> <a href="javascript:window.close();">Close</a></p>'; echo $successMsg; exit(); } $sql = mysql_query("SELECT * FROM company_info WHERE proj_id='$cust_project_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { $company_name = $row["company_name"]; $company_contact_fname = $row["contact_fname"]; $company_contact_lname = $row["contact_lname"]; $company_address = $row["address"]; $customer_city = $row["city"]; $customer_state = $row["state"]; $customer_zip = $row["zip"]; $customer_email = $row["email"]; $customer_phone = $row["phone"]; $customer_fax = $row["fax"]; $cust_pre_meth_contact = $row["pref_meth_contact"]; $cust_entry_date = $row["entry_date"]; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.form.company_name.value == "" ) { alert ( "Company Name field must not be blank." ); valid = false; } if ( document.form.customer_fname.value == "" ) { alert ( "Customer Address field must not be blank." ); valid = false; } if ( document.form.customer_lname.value == "" ) { alert ( "Customer Address field must not be blank." ); valid = false; } if ( document.form.customer_address.value == "" ) { alert ( "Customer Address field must not be blank." ); valid = false; } if ( document.form.customer_city.value == "" ) { alert ( "Customer City field must not be blank." ); valid = false; } if ( document.form.customer_state.value == "" ) { alert ( "Customer State field must not be blank." ); valid = false; } if ( document.form.customer_zip.value == "" ) { alert ( "Customer Password field must not be blank." ); valid = false; } if ( document.form.customer_email.value == "" ) { alert ( "Customer Email field must not be blank." ); valid = false; } if ( document.form.customer_phone.value == "" ) { alert ( "Customer Phone field must not be blank." ); valid = false; } if ( document.form.customer_fax.value == "" ) { alert ( "Customer Fax field must not be blank." ); valid = false; } return valid; } <!-- Form Validation --> </script> </head> <body> <div id="pg_container"> <!--PAGE CONTAINER--> <div id="pgbdy_container"> <div id="pgbdy"> <div id="bdy_header"></div> <div id="bdy_content_area"> <div id="bdy_content"> <div id="bdy_form_header"> <p> Create a new customer by filling out the form below.<br /> <i>Fields marked with a</i> <b>*</b> <i>are required fields.</i> </p> </div> <form action="edit_company_info.php?sid=<?php echo "$staff_id"; ?>&cid=<?php echo "$customer_id"; ?>&pid=<?php echo "$cust_project_id"; ?>" method="post" id="form" name="form" enctype="multipart/form-data" onsubmit="return validate_form ( );"> <!-- COMPANY NAME --> <div id="company_name_form"> <div id="company_name_text"> <p> Company Name: </p> </div> <div id="company_name_field"> <input name="company_name" type="text" id="company_name" value="<?php echo "$company_name"; ?>" /> </div> </div> <!--COMPANY NAME--> <!-- CUSTOMER FIRST NAME --> <div id="customer_fname_form"> <div id="customer_fname_text"> <p> Contact First Name: </p> </div> <div id="customer_fname_field"> <input name="customer_fname" type="text" id="customer_fname" value="<?php echo "$company_contact_fname"; ?>" /> </div> </div> <!-- CUSTOMER FIRST NAME --> <!-- CUSTOMER LAST NAME --> <div id="customer_lname_form"> <div id="customer_lname_text"> <p> Contact Last Name: </p> </div> <div id="customer_lname_field"> <input name="customer_lname" type="text" id="customer_lname" value="<?php echo "$company_contact_lname"; ?>" /> </div> </div> <!-- CUSTOMER LAST NAME --> <!-- CUSTOMER ADDRESS --> <div id="customer_address_form"> <div id="customer_address_text"> <p> Address: </p> </div> <div id="customer_address_field"> <input name="customer_address" type="text" id="customer_address" value="<?php echo "$company_address"; ?>" /> </div> </div> <!--CUSTOMER ADDRESS--> <!-- CUSTOMER CITY --> <div id="customer_city_form"> <div id="customer_city_text"> <p> City: </p> </div> <div id="company_name_field"> <input name="customer_city" type="text" id="customer_city" value="<?php echo "$customer_city"; ?>" /> </div> </div> <!--CUSTOMER CITY--> <!-- CUSTOMER STATE --> <div id="customer_state_form"> <div id="customer_state_text"> <p> State: </p> </div> <div id="customer_state_field"> <input name="customer_state" type="text" id="customer_state" value="<?php echo "$customer_state"; ?>" /> </div> </div> <!--CUSTOMER STATE--> <!-- CUSTOMER ZIP --> <div id="customer_zip_form"> <div id="customer_zip_text"> <p> Zip: </p> </div> <div id="customer_zip_field"> <input name="customer_zip" type="text" id="customer_zip" value="<?php echo "$customer_zip"; ?>" /> </div> </div> <!--CUSTOMER ZIP--> <!-- CUSTOMER EMAIL --> <div id="customer_email_form"> <div id="customer_email_text"> <p> Email: </p> </div> <div id="customer_email_field"> <input name="customer_email" type="text" id="customer_email" value="<?php echo "$customer_email"; ?>" /> </div> </div> <!--CUSTOMER EMAIL--> <!-- CUSTOMER PHONE--> <div id="customer_phone_form"> <div id="customer_phone_text"> <p> Phone: </p> </div> <div id="customer_phone_field"> <input name="customer_phone" type="text" id="customer_phone" value="<?php echo "$customer_phone"; ?>" /> </div> </div> <!--CUSTOMER PHONE--> <!-- CUSTOMER FAX--> <div id="customer_fax_form"> <div id="customer_fax_text"> <p> Fax: </p> </div> <div id="customer_fax_field"> <input name="customer_fax" type="text" id="customer_fax" value="<?php echo "$customer_fax"; ?>" /> </div> </div> <!--CUSTOMER FAX--> <!-- CUSTOMER PREFERRED METHOD OF CONTACT --> <div id="cust_pre_meth_contact_form"> <div id="cust_pre_meth_contact_text"> <p> What is the customer's preferred method of contact?<br /> <select name="cust_pre_meth_contact"> <option value="Email">Email</option> <option value="Fax">Fax</option> <option value="Phone">Phone</option> <option value="Physical Mail">Physical Mail</option> </select> </p> </div> </div> <!--CUSTOMER PREFERRED METHOD OF CONTACT --> <!-- SUBMIT BUTTON --> <div id="submit_new_customer_form"> <div id="submit_new_customer_button"> <p> <input name="submit_new_customer_info" type="submit" id="submit_new_customer" value="Update Customer Company Info" /> </p> </div> </div> </form> <!--SUBMIT BUTTON--> </div> </div> </div> </div> <!--PAGE CONTAINER--> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/ Share on other sites More sharing options...
gristoi Posted March 31, 2011 Share Posted March 31, 2011 Try posting the form with the action filled out: < form action ="<?php echo $_SERVER['php_self'] ?> Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195180 Share on other sites More sharing options...
kenrbnsn Posted March 31, 2011 Share Posted March 31, 2011 A blank action in a form automatically gets submitted back to the same script. Ken Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195182 Share on other sites More sharing options...
ManiacDan Posted March 31, 2011 Share Posted March 31, 2011 I see probably 1,500 lines of code without a single error reporting function. How have you been doing this for "so[ox5] long" without using mysql_error() ? Have you tried that? Have you turned error_reporting all the way up? Have you tried putting debug echoes in this script to see what the values of everything are? ereg is deprecated and should not be used. Since you don't know that, I'm assuming your errors are set to a level that hides the deprecation warning. Set error_reporting(E_ALL) at the top of your script, and make use of mysql_error(). -Dan Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195185 Share on other sites More sharing options...
Bl4ckMaj1k Posted March 31, 2011 Author Share Posted March 31, 2011 By default, the code calls itself in the case of a null action. None the less, I gave it a shot, still nothing.... :'( Whats really grinding my gears here is the fact that I have two IDENTICAL codes, all written in the same fashion. When I test those, they write to their respective tables just fine. When I write to this other table, I am getting an error....like....come onnnnn!!! lol, how is that even possible?? Below I have provided more structural detail so you can see how things work in this project. User clicks a button which creates a project ID. Project ID gets submitted to three tables General Info Table Company Info Table Billing Table From there of course each one of these tables have their own IDs with auto increment set. Next I do the actual update of the information. I fill out a form called edit_general_info.php?sid=1&cid=3&pid=3-003-0042 (<-- exmaple link) and upon submission it updates the General Info table WHERE project id = the project id from the link...in this case 3-003-0042. I know its capturing the project ID correctly. The same process is working for Company Info Table. Why would this error out on the Billing Table?? PHP can be your bestest most bestest buddy one day then a complete A-HOLE the next.....im gonna rip my EYES out guys lol. Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195190 Share on other sites More sharing options...
Bl4ckMaj1k Posted March 31, 2011 Author Share Posted March 31, 2011 EDIT: Just echoed ALL variables successfully. It is in fact pulling the submitted user data from the form. Its just not transferring that data over to the database. I see probably 1,500 lines of code without a single error reporting function. How have you been doing this for "so[ox5] long" without using mysql_error() ? Have you tried that? Have you turned error_reporting all the way up? Have you tried putting debug echoes in this script to see what the values of everything are? ereg is deprecated and should not be used. Since you don't know that, I'm assuming your errors are set to a level that hides the deprecation warning. Set error_reporting(E_ALL) at the top of your script, and make use of mysql_error(). -Dan Totally understand and agree....I was going to come back to the error reporting and conditional statement to ensure everything was working ok. As of now, I just assume everything is working correctly if I get to the bottom of my if statement....which I do. Still, none the less, I went ahead and added your error function right below my session variable. There were no errors or issues whatsoever. Even though thats the case, I STILL don't write any data to my table. I built a small test PHP script just to make sure my table wasn't the issue. I had it write to the billing_info table and it wrote to it successfully....still completely lost. Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195196 Share on other sites More sharing options...
Psycho Posted March 31, 2011 Share Posted March 31, 2011 As ManiacDan was saying you need to incorporate debugging code. In my opinion, this should be done as part of the coding process. It is very easy to implement debugging into your code so that it is not exposed in a production environment. I like to create a debugging function that will echo/not echo the debugging info to the page based upon a switch that I can turn on or off. That way I can leave the debugging code in place even when I *think* I am done with the script. If I run into a problem later I just turn debugging back on. Also, You should always create your queries as a string variable THEN run the mysql_query(). If there are any problems you can echo the query to the page to validate that the values are what you expect. Your query is likely failing. Try the following: <?php session_start(); $successMsg = ''; $staff_id = $_SESSION['sid']; include_once "scripts/connect_to_mysql.php"; $customer_id = $_GET['cid']; $customer_id = mysql_real_escape_string($customer_id ); $customer_id = eregi_replace("`", "", $customer_id); $cust_project_id = $_GET['pid']; $cust_project_id = mysql_real_escape_string($cust_project_id ); $cust_project_id = eregi_replace("`", "", $cust_project_id); if (isset($_POST['billing_contact_fax_form_field_box'])) { $billing_contact_fname_form_field_box = $_POST['billing_contact_fname_form_field_box']; $billing_contact_lname_form_field_box = $_POST['billing_contact_lname_form_field_box']; $billing_contact_address_form_field_box = $_POST['billing_contact_address_form_field_box']; $billing_contact_city_form_field_box = $_POST['billing_contact_city_form_field_box']; $billing_contact_state_form_field_box = $_POST['billing_contact_state_form_field_box']; $billing_contact_zip_form_field_box = $_POST['billing_contact_zip_form_field_box']; $billing_contact_email_form_field_box = $_POST['billing_contact_email_form_field_box']; $billing_contact_phone_form_field_box = $_POST['billing_contact_phone_form_field_box']; $billing_contact_fax_form_field_box = $_POST['billing_contact_fax_form_field_box']; $billing_contact_pref_meth_contact_form_field_box = $_POST['billing_contact_pref_meth_contact_form_field_box']; $billing_contact_cc_billed_form_field_box = $_POST['billing_contact_cc_billed_form_field_box']; $query = "UPDATE billing_info SET contact_fname='$billing_contact_fname_form_field_box', contact_lame='$billing_contact_lname_form_field_box', address='$billing_contact_address_form_field_box', city='$billing_contact_city_form_field_box', state='$billing_contact_state_form_field_box', zip='$billing_contact_zip_form_field_box', email='$billing_contact_email_form_field_box', phone='$billing_contact_phone_form_field_box', fax='$billing_contact_fax_form_field_box', pref_meth_contact='$billing_contact_pref_meth_contact_form_field_box', cc_billed='$billing_contact_cc_billed_form_field_box' WHERE proj_id='$cust_project_id'"; echo "Query:<br />$query<br /><br />"; $sql = mysql_query($query) or die(mysql_error()); $successMsg = '<p style="font-family:Myriad Web Pro" style="font-size:10px" style="color:#666">You have successfully updated the company\'s General Information.<br /><br /> <a href="javascript:window.close();">Close</a></p>'; echo $successMsg; exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195203 Share on other sites More sharing options...
Bl4ckMaj1k Posted March 31, 2011 Author Share Posted March 31, 2011 Wow I feel like a COMPLETE moron!!!!! Thanks MJDamato and everyone else for the debugging assistance. After running MJs code I was able to see EXACTLY what my issue was. It actually displayed the issue to me on screen....almost like my code was communicating to me....AWESOME!!! If you look at the way I spelled 'contact_lname' in the query, you will see that I am missing the letter 'n'....I just have 'contact_lame' LOL. I am sorry for wasting you guys' time. Now I can see the EXTREME importance of debugging. Can someone teach me the gist of it so I can start applying it to all my code?? I have finally gotten comfortable coding from scratch (blank documents feel so much better after you have filled them with code....and I am not talking copy and paste work!!) and now I realize that I have passed up a major step. Any help with this would be perfect!!!! Thanks for the help guys!!! I sincerely appreciate it!!! Bl4ck Maj1k Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195208 Share on other sites More sharing options...
Psycho Posted March 31, 2011 Share Posted March 31, 2011 Here is a sample script with a debugging function implemented. You can turn debugging on/off with the first variable. You would want debugging code used in key places in your code, such as: - any branching logic (If/Else or switch statements) - where variables are set/changed to verify the values - when performing certain operations that could fail (DB queries, reading files, etc.) <?php session_start(); //Var to determine if debugging is on or off $debugMode = true; function debug($debugText, $file='Unknown', $line='xx') { global $debugMode; //Do nothing if debug mode is not on if(!$debugMode) { return false; } //Display debug message echo "<b>DEBUG [{$file}: {$line}]:</b><br />\n"; echo "{$debugText}<br /><br />\n"; return; } if($foo == $bar) { debug("\$foo ($foo) equals \$bar ($bar)", __FILE__, __LINE__); $query = "SELECT * FROM table WHERE fieldName = '$somevalue'"; $result = mysql_query($query); if(!result) { debug("Query Succeeded: {$query}", __FILE__, __LINE__); //Do some other stuff } else { debug("Query Failes: {$query}<br />Error".mysql_error(), __FILE__, __LINE__); //Do some other stuff } } else { debug("\$foo ($foo) doe not equals \$bar ($bar)", __FILE__, __LINE__); //Do some other stuff } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195259 Share on other sites More sharing options...
Bl4ckMaj1k Posted April 1, 2011 Author Share Posted April 1, 2011 Wow thanks for all that code!! I will play around with this first thing tomorrow. I am guessing that the only static information in this file is the portion that reads __FILE__ and __LINE__..... I am afraid I have never seen the two. Are those actual functions? You don't have to answer these questions. I can always Google them. Also, would this have to be run for every particular function that I am attempting? In which case I would be doing everything one by one? Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195379 Share on other sites More sharing options...
Psycho Posted April 1, 2011 Share Posted April 1, 2011 I am guessing that the only static information in this file is the portion that reads __FILE__ and __LINE__..... I am afraid I have never seen the two. Are those actual functions? Those are PHP magic constants that return the currently running file name and line number of the file. That way, when you see your debug information, if something seems out of place it gives you an idea of where to look in your code. Also, would this have to be run for every particular function that I am attempting? In which case I would be doing everything one by one? No idea what you are talking about. The example above is for illustrative purposes. In that example you would make a call to the debug() function any place that makes sense. Just pass whatever text/values that would be helpful for the particular situation along with the magic constants so you can see where the debug was called from. Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195391 Share on other sites More sharing options...
Bl4ckMaj1k Posted April 1, 2011 Author Share Posted April 1, 2011 LOL no idea what I was talking about but somehow answered my question exactly!!!!! Thanks. This is amazing, I truly appreciate you taking the time to show this to me. Bl4ck Maj1k Quote Link to comment https://forums.phpfreaks.com/topic/232327-i-am-gonna-pull-my-eyes-out-what-is-wrong-here/#findComment-1195468 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.