KevinM1 Posted July 2, 2007 Share Posted July 2, 2007 I have a custom registration form which I've integrated into PHP-Fusion. It worked fine until this morning. Now I can't save the info to the database. I'm not getting any errors, MySQL or otherwise, and the stuff that's supposed to happen upon successful submission is happening (the e-mail is sent and I'm redirected to the success page), but nothing is being written to the database. My code: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; function myEscape($string){ return (get_magic_quotes_gpc) ? mysql_real_escape_string(stripslashes($string)) : mysql_real_escape_string($string); } if(file_exists(INFUSIONS."aw_ecal_panel/locale/".$settings['locale'].".php")) { include INFUSIONS."aw_ecal_panel/locale/".$settings['locale'].".php"; } else { include INFUSIONS."aw_ecal_panel/locale/German.php"; } if(!iMEMBER){ fallback(); } if(isset($_GET['evid'])){ $ev = dbquery("SELECT * FROM ".DB_PREFIX."aw_ec_events WHERE ev_id=". $_GET['evid']); $event = dbarray($ev); $ev_id = $event['ev_id']; $user_id = $userdata['user_id']; $ev_title = $event['ev_title']; $ev_start = $event['ev_start']; $ev_end = $event['ev_end']; } $errMessage = NULL; if(isset($_POST['submit'])){ $ev = dbquery("SELECT * FROM ".DB_PREFIX."aw_ec_events WHERE ev_id=". $_POST['evid']); $event = dbarray($ev); $ev_id = $event['ev_id']; $user_id = $userdata['user_id']; $ev_title = $event['ev_title']; $ev_start = $event['ev_start']; $ev_end = $event['ev_end']; if(!empty($_POST['regAgent']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['regAgent'])){ $regAgent = myEscape($_POST['regAgent']); $ra = TRUE; } else{ $errMessage .= "Please enter your name!<br />\n"; } if(!empty($_POST['agentWritingNum']) && preg_match("/^[0-9a-zA-Z]*$/i", $_POST['agentWritingNum'])){ $agentWritingNum = myEscape($_POST['agentWritingNum']); $awn = TRUE; } else{ $errMessage .= "Please enter your writing number!<br />\n"; } if(!empty($_POST['phoneNum'])){ $phoneNum = $_POST['phoneNum']; if(preg_match("/^[0-9]{3}$/i", $phoneNum[0]) && preg_match("/^[0-9]{3}$/i", $phoneNum[1]) && preg_match("/^[0-9]{4}$/i", $phoneNum[2])){ $areaCode = myEscape($phoneNum[0]); $firstPart = myEscape($phoneNum[1]); $secondPart = myEscape($phoneNum[2]); $phoneText = "$areaCode-$firstPart-$secondPart"; $phone = TRUE; } else{ $errMessage .= "Please enter your correct phone number!<br />\n"; } } else{ $errMessage .= "Please enter your phone number!<br />\n"; } if(!empty($_POST['emailAddress']) && preg_match("/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/i", $_POST['emailAddress'])){ $email = myEscape($_POST['emailAddress']); $e = TRUE; } else{ $errMessage .= "Please enter your e-mail address!<br />\n"; } if(!empty($_POST['regionalSales']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['regionalSales'])){ $regSales = myEscape($_POST['regionalSales']); $rs = TRUE; } else{ $errMessage .= "Please enter the name of your regional sales coordinator!<br />\n"; } if(!empty($_POST['districtSales']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['districtSales'])){ $disSales = myEscape($_POST['districtSales']); $ds = TRUE; } else{ $errMessage .= "Please enter the name of your district sales coordinator!<br />\n"; } if($ra && $awn && $phone && $email && $rs && $ds){ //start the big process of updating tables and e-mailing results $timestamp = strtotime("now"); $aflacCheck = "SELECT * FROM ".DB_PREFIX."aflac WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $aflacCheckResult = dbquery($aflacCheck); if($aflacCheckResult){ $aflacQuery = "UPDATE ".DB_PREFIX."aflac SET registering_agent='".$regAgent."', agent_writing_number='".$agentWritingNum."', phone='".$phoneText."', email='".$email."', regional_sales_coordinator='".$regSales."', district_sales_coordinator='".$disSales."', ev_title='".$ev_title."', ev_start='".$ev_start."', ev_end='".$ev_end."', login_timestamp='".$timestamp."', login_status='1' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $aflacResult = dbquery($aflacQuery); } else{ $aflacQuery = "INSERT INTO ".DB_PREFIX."aflac (registering_agent, agent_writing_number, phone, email, regional_sales_coordinator, district_sales_coordinator, ev_id, user_id, ev_title, ev_start, ev_end, login_timestamp, login_status) VALUES ('". $regAgent ."', '". $agentWritingNum ."', '". $phoneText ."', '". $email ."', '". $regSales ."', '". $disSales ."', '". $ev_id ."', '". $user_id ."', '". $ev_title ."', '". $ev_start ."', '". $ev_end ."', '". $timestamp ."', '1')"; $aflacResult = dbquery($aflacQuery); } $eventQuery = "UPDATE ".DB_PREFIX."aw_ec_events SET ev_allow_logins='1' WHERE ev_id='".$ev_id."'"; $eventResult = dbquery($eventQuery); $loginsCheck = "SELECT * FROM ".DB_PREFIX."aw_ec_logins WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $loginsCheckResult = dbquery($loginsCheck); if($loginsCheckResult){ $loginsQuery = "UPDATE ".DB_PREFIX."aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='".$timestamp."' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $loginsResult = dbquery($loginsQuery); } else{ $loginsQuery = "INSERT INTO ".DB_PREFIX."aw_ec_logins (ev_id, user_id, login_comment, login_status, login_timestamp) VALUES ('". $ev_id ."', '". $user_id ."', 'Definitely Agreed', '1', '". $timestamp ."')"; $loginsResult = dbquery($loginsQuery); } if($aflacResult && $eventResult && $loginsResult){ $eventTimestamp = strtotime($ev_start); $eventDate = date("m-d-Y h:i:s T", $eventTimestamp); $userName = $userdata['user_name']; $to = "rebecca_dunkle@us.aflac.com"; $subject = "Event Registration ($ev_title)"; $mailMessage = "<html>\n<head>\n<title>Event Registration Information</title>\n</head>\n\n<body>"; $mailMessage .= "Below is the registration information:<br />\n<br />\n"; $mailMessage .= "Event Name: $ev_title<br />\nEvent Date: $eventDate<br />\nRegistering Agent: $regAgent<br />\nUser Name: $userName<br />\n"; $mailMessage .= "Agent Writing Number: $agentWritingNum<br />\nPhone Number: $phoneText<br />\n"; $mailMessage .= "E-mail Address: $email<br />\nRegional Sales Coordinator: $regSales<br />\n"; $mailMessage .= "District Sales Coordinator: $disSales<br />\n</body>\n</html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $mailMessage, $headers); header("Location: success.php?user=$userName&event=$ev_title"); } else{ echo "<br />Something went wrong with the insert!<br /><br />\n\n"; } } else{ echo "<div style='color: red;'>$errMessage</div><br />"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Registration Form</title> <link rel="stylesheet" type="text/css" href="formstyles.css"> </head> <body style="text-align: center;"> <div style="width: 400px; margin: 0 auto;"> Registration Form<br /><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?evid=<?php echo $ev_id; ?>" method="post"> <fieldset class="narrow"><legend>Please input your information</legend> <p><label for="regAgent">Registering Agent:</label><input type="text" name="regAgent" value="<?php if(isset($_POST['regAgent'])){echo $_POST['regAgent'];} ?>" /></p> <p><label for="agentWritingNum">Agent Writing Number:</label><input type="text" name="agentWritingNum" value="<?php if(isset($_POST['agentWritingNum'])){echo $_POST['agentWritingNum'];} ?>" /></p> <p><label for="phoneNum">Phone Number:</label>(<input type="text" name="phoneNum[]" size="3" maxlength="3" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][0];} ?>" />) - <input type="text" name="phoneNum[]" size="3" maxlength="3" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][1];} ?>" /> - <input type="text" name="phoneNum[]" size="4" maxlength="4" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][2];} ?>" /></p> <p><label for="emailAddress">E-mail Address:</label><input type="text" name="emailAddress" value="<?php if(isset($_POST['emailAddress'])){echo $_POST['emailAddress'];} ?>" /></p> <p><label for="regionalSales">Regional Sales Coordinator:</label><input type="text" name="regionalSales" value="<?php if(isset($_POST['regionalSales'])){echo $_POST['regionalSales'];} ?>" /></p> <p><label for="districtSales">District Sales Coordinator:</label><input type="text" name="districtSales" value="<?php if(isset($_POST['districtSales'])){echo $_POST['districtSales'];} ?>" /></p> </fieldset> <input type="hidden" name="evid" value="<?php echo $ev_id; ?>" /> <p><input type="submit" name="submit" value="Submit" /></p> </form> </div> </body> </html> <?php require_once "side_right.php"; require_once "footer.php"; ?> Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/ Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 12 views and no response? C'mon guys, I really need help here. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288077 Share on other sites More sharing options...
AndyB Posted July 2, 2007 Share Posted July 2, 2007 "It worked fine until this morning". OK, and what changes have you made since then? What changes has your host made since then? Is error_reporting ON? Is error_display ON? Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288089 Share on other sites More sharing options...
GingerRobot Posted July 2, 2007 Share Posted July 2, 2007 12 views and no response? C'mon guys, I really need help here. You really wont help your chances of getting a response by posting comments like that. People are not obliged to help you. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288097 Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 "It worked fine until this morning". OK, and what changes have you made since then? What changes has your host made since then? Is error_reporting ON? Is error_display ON? I made simple changes, adding else if(isset($_GET['registering_agent'])){echo $_GET['registering_agent'];} and the like to the form. But here's the thing, my non-edited version also won't work. I tried it on both my test site and the live site and, again, nothing is being written to the database. I've turned error_reporting to all and error_display on. I get the following errors (actually, the same one repeated several times): Notice: Use of undefined constant get_magic_quotes_gpc - assumed 'get_magic_quotes_gpc' in /home/nights/www/www/registration.php on line 11 Would something like this prevent values from being assigned? As you can see from my code above, I use myEscape() on the values entered by the user. The funny thing is, again, I used it this morning -- with the same myEscape() function -- to edit an entry. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288111 Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 Well, I fixed the get_magic_quotes_gpc issue. That removed the error, but the values still won't write to the database. EDIT: and my host hasn't made any changes. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288117 Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 Another oddity: I can echo the values upon form submission. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288140 Share on other sites More sharing options...
AndyB Posted July 2, 2007 Share Posted July 2, 2007 If writing to the database is the problem, it would be well worth while echoing every querystring so that you can see what the actual query is, as opposed to hoping it's what you expect it to be. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288151 Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 If writing to the database is the problem, it would be well worth while echoing every querystring so that you can see what the actual query is, as opposed to hoping it's what you expect it to be. It looks like it's defaulting to using the UPDATE...SET syntax. Apparently my if($aflacResult && $eventsResult && $loginsResult) conditional isn't working correctly. I'm not sure why, though, as the dbquery() function, which is what I use to process all of my queries (found in maincore.php), is simply: <?php function dbquery($query) { $result = @mysql_query($query); if (!$result) { echo mysql_error(); return false; } else { return $result; } } ?> It should return false if my SELECT queries find get anything (which they can't in the aflac and aw_ec_logins tables as, right now, there's nothing in them), forcing my queries to use INSERT rather than UPDATE...SET. But it's not doing that. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288170 Share on other sites More sharing options...
AndyB Posted July 2, 2007 Share Posted July 2, 2007 I'll leave you to figure out the apparent logical problem you described, but UPDATE queries actually need a WHERE condition so they'll know which db record to update. I don't see that in your update queries. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288182 Share on other sites More sharing options...
shage Posted July 2, 2007 Share Posted July 2, 2007 12 views and no response? C'mon guys, I really need help here. You really wont help your chances of getting a response by posting comments like that. People are not obliged to help you. u get them ben with your bad self Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288189 Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 I'll leave you to figure out the apparent logical problem you described, but UPDATE queries actually need a WHERE condition so they'll know which db record to update. I don't see that in your update queries. Too many versions of my file floating around.... Here's the current version: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; error_reporting(E_ALL); ini_set('error_display', 'on'); /* function myEscape($string){ return (get_magic_quotes_gpc()) ? mysql_real_escape_string(stripslashes($string)) : mysql_real_escape_string($string); } */ if(file_exists(INFUSIONS."aw_ecal_panel/locale/".$settings['locale'].".php")) { include INFUSIONS."aw_ecal_panel/locale/".$settings['locale'].".php"; } else { include INFUSIONS."aw_ecal_panel/locale/German.php"; } if(!iMEMBER){ fallback(); } if(isset($_GET['evid'])){ $ev = dbquery("SELECT * FROM ".DB_PREFIX."aw_ec_events WHERE ev_id=". $_GET['evid']); $event = dbarray($ev); $ev_id = $event['ev_id']; $user_id = $userdata['user_id']; $ev_title = $event['ev_title']; $ev_start = $event['ev_start']; $ev_end = $event['ev_end']; } $errMessage = NULL; if(isset($_POST['submit'])){ $ev = dbquery("SELECT * FROM ".DB_PREFIX."aw_ec_events WHERE ev_id=". $_POST['evid']); $event = dbarray($ev); $ev_id = $event['ev_id']; $user_id = $userdata['user_id']; $ev_title = $event['ev_title']; $ev_start = $event['ev_start']; $ev_end = $event['ev_end']; if(!empty($_POST['regAgent']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['regAgent'])){ $regAgent = $_POST['regAgent']; //myEscape($_POST['regAgent']); $ra = TRUE; } else{ $errMessage .= "Please enter your name!<br />\n"; } if(!empty($_POST['agentWritingNum']) && preg_match("/^[0-9a-zA-Z]*$/i", $_POST['agentWritingNum'])){ $agentWritingNum = $_POST['agentWritingNum']; //myEscape($_POST['agentWritingNum']); $awn = TRUE; } else{ $errMessage .= "Please enter your writing number!<br />\n"; } if(!empty($_POST['phoneNum'])){ $phoneNum = $_POST['phoneNum']; if(preg_match("/^[0-9]{3}$/i", $phoneNum[0]) && preg_match("/^[0-9]{3}$/i", $phoneNum[1]) && preg_match("/^[0-9]{4}$/i", $phoneNum[2])){ $areaCode = $phoneNum[0]; //myEscape($phoneNum[0]); $firstPart = $phoneNum[1]; //myEscape($phoneNum[1]); $secondPart = $phoneNum[2]; //myEscape($phoneNum[2]); $phoneText = "$areaCode-$firstPart-$secondPart"; $phone = TRUE; } else{ $errMessage .= "Please enter your correct phone number!<br />\n"; } } else{ $errMessage .= "Please enter your phone number!<br />\n"; } if(!empty($_POST['emailAddress']) && preg_match("/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/i", $_POST['emailAddress'])){ $email = $_POST['emailAddress']; //myEscape($_POST['emailAddress']); $e = TRUE; } else{ $errMessage .= "Please enter your e-mail address!<br />\n"; } if(!empty($_POST['regionalSales']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['regionalSales'])){ $regSales = $_POST['regionalSales']; //myEscape($_POST['regionalSales']); $rs = TRUE; } else{ $errMessage .= "Please enter the name of your regional sales coordinator!<br />\n"; } if(!empty($_POST['districtSales']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['districtSales'])){ $disSales = $_POST['districtSales']; //myEscape($_POST['districtSales']); $ds = TRUE; } else{ $errMessage .= "Please enter the name of your district sales coordinator!<br />\n"; } if($ra && $awn && $phone && $email && $rs && $ds){ //start the big process of updating tables and e-mailing results $timestamp = strtotime("now"); echo "SELECT * FROM ".DB_PREFIX."aflac WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $aflacCheck = "SELECT * FROM ".DB_PREFIX."aflac WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $aflacCheckResult = dbquery($aflacCheck); if($aflacCheckResult){ echo "UPDATE ".DB_PREFIX."aflac SET registering_agent='".$regAgent."', agent_writing_number='".$agentWritingNum."', phone='".$phoneText."', email='".$email."', regional_sales_coordinator='".$regSales."', district_sales_coordinator='".$disSales."', ev_title='".$ev_title."', ev_start='".$ev_start."', ev_end='".$ev_end."', login_timestamp='".$timestamp."', login_status='1' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $aflacQuery = "UPDATE ".DB_PREFIX."aflac SET registering_agent='".$regAgent."', agent_writing_number='".$agentWritingNum."', phone='".$phoneText."', email='".$email."', regional_sales_coordinator='".$regSales."', district_sales_coordinator='".$disSales."', ev_title='".$ev_title."', ev_start='".$ev_start."', ev_end='".$ev_end."', login_timestamp='".$timestamp."', login_status='1' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $aflacResult = dbquery($aflacQuery); } else{ echo "INSERT INTO ".DB_PREFIX."aflac (registering_agent, agent_writing_number, phone, email, regional_sales_coordinator, district_sales_coordinator, ev_id, user_id, ev_title, ev_start, ev_end, login_timestamp, login_status) VALUES ('". $regAgent ."', '". $agentWritingNum ."', '". $phoneText ."', '". $email ."', '". $regSales ."', '". $disSales ."', '". $ev_id ."', '". $user_id ."', '". $ev_title ."', '". $ev_start ."', '". $ev_end ."', '". $timestamp ."', '1')<br /><br />"; $aflacQuery = "INSERT INTO ".DB_PREFIX."aflac (registering_agent, agent_writing_number, phone, email, regional_sales_coordinator, district_sales_coordinator, ev_id, user_id, ev_title, ev_start, ev_end, login_timestamp, login_status) VALUES ('". $regAgent ."', '". $agentWritingNum ."', '". $phoneText ."', '". $email ."', '". $regSales ."', '". $disSales ."', '". $ev_id ."', '". $user_id ."', '". $ev_title ."', '". $ev_start ."', '". $ev_end ."', '". $timestamp ."', '1')"; $aflacResult = dbquery($aflacQuery); } echo "UPDATE ".DB_PREFIX."aw_ec_events SET ev_allow_logins='1' WHERE ev_id='".$ev_id."'<br /><br />"; $eventQuery = "UPDATE ".DB_PREFIX."aw_ec_events SET ev_allow_logins='1' WHERE ev_id='".$ev_id."'"; $eventResult = dbquery($eventQuery); echo "SELECT * FROM ".DB_PREFIX."aw_ec_logins WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $loginsCheck = "SELECT * FROM ".DB_PREFIX."aw_ec_logins WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $loginsCheckResult = dbquery($loginsCheck); if($loginsCheckResult){ echo "UPDATE ".DB_PREFIX."aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='".$timestamp."' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $loginsQuery = "UPDATE ".DB_PREFIX."aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='".$timestamp."' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $loginsResult = dbquery($loginsQuery); } else{ echo "INSERT INTO ".DB_PREFIX."aw_ec_logins (ev_id, user_id, login_comment, login_status, login_timestamp) VALUES ('". $ev_id ."', '". $user_id ."', 'Definitely Agreed', '1', '". $timestamp ."')<br /><br />"; $loginsQuery = "INSERT INTO ".DB_PREFIX."aw_ec_logins (ev_id, user_id, login_comment, login_status, login_timestamp) VALUES ('". $ev_id ."', '". $user_id ."', 'Definitely Agreed', '1', '". $timestamp ."')"; $loginsResult = dbquery($loginsQuery); } if($aflacResult && $eventResult && $loginsResult){ $eventTimestamp = strtotime($ev_start); $eventDate = date("m-d-Y h:i:s T", $eventTimestamp); $userName = $userdata['user_name']; $to = "kevinmajor1@gmail.com"; $subject = "Event Registration ($ev_title)"; $mailMessage = "<html>\n<head>\n<title>Event Registration Information</title>\n</head>\n\n<body>"; $mailMessage .= "Below is the registration information:<br />\n<br />\n"; $mailMessage .= "Event Name: $ev_title<br />\nEvent Date: $eventDate<br />\nRegistering Agent: $regAgent<br />\nUser Name: $userName<br />\n"; $mailMessage .= "Agent Writing Number: $agentWritingNum<br />\nPhone Number: $phoneText<br />\n"; $mailMessage .= "E-mail Address: $email<br />\nRegional Sales Coordinator: $regSales<br />\n"; $mailMessage .= "District Sales Coordinator: $disSales<br />\n</body>\n</html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $mailMessage, $headers); // header("Location: success.php?user=$userName&event=$ev_title"); echo "Registering Agent: $regAgent, Agent Writing Number: $agentWritingNum, Phone Number: $phoneText, E-mail Address: $email, Regional Sales Coordinator: $regSales, District Sales Coordinator: $disSales, Event ID: $ev_id, User ID: $user_id<br /><br />"; } else{ echo "<br />Something went wrong with the insert!<br /><br />\n\n"; } } else{ echo "<div style='color: red;'>$errMessage</div><br />"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Registration Form</title> <link rel="stylesheet" type="text/css" href="formstyles.css"> </head> <body style="text-align: center;"> <div style="width: 400px; margin: 0 auto;"> Registration Form<br /><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?evid=<?php echo $ev_id; ?>" method="post"> <fieldset class="narrow"><legend>Please input your information</legend> <p><label for="regAgent">Registering Agent:</label><input type="text" name="regAgent" value="<?php if(isset($_POST['regAgent'])){echo $_POST['regAgent'];} ?>" /></p> <p><label for="agentWritingNum">Agent Writing Number:</label><input type="text" name="agentWritingNum" value="<?php if(isset($_POST['agentWritingNum'])){echo $_POST['agentWritingNum'];} ?>" /></p> <p><label for="phoneNum">Phone Number:</label>(<input type="text" name="phoneNum[]" size="3" maxlength="3" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][0];} ?>" />) - <input type="text" name="phoneNum[]" size="3" maxlength="3" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][1];} ?>" /> - <input type="text" name="phoneNum[]" size="4" maxlength="4" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][2];} ?>" /></p> <p><label for="emailAddress">E-mail Address:</label><input type="text" name="emailAddress" value="<?php if(isset($_POST['emailAddress'])){echo $_POST['emailAddress'];} ?>" /></p> <p><label for="regionalSales">Regional Sales Coordinator:</label><input type="text" name="regionalSales" value="<?php if(isset($_POST['regionalSales'])){echo $_POST['regionalSales'];} ?>" /></p> <p><label for="districtSales">District Sales Coordinator:</label><input type="text" name="districtSales" value="<?php if(isset($_POST['districtSales'])){echo $_POST['districtSales'];} ?>" /></p> </fieldset> <input type="hidden" name="evid" value="<?php echo $ev_id; ?>" /> <p><input type="submit" name="submit" value="Submit" /></p> </form> </div> </body> </html> <?php require_once "side_right.php"; require_once "footer.php"; ?> As you can see, all queries have WHERE clauses, but the problem remains. mysql_query() should return false on an empty result, correct? I'm asking because I've gone over both the code and the actual queries and I can't see where a logic error could possibly occur, unless the dbquery() function isn't behaving properly. Like I said before, there's literally nothing in the aflac and aw_ec_logins tables right now, so the dbquery() function should be returning false when I check those two tables, forcing it to INSERT rather than UPDATE. EDIT: Here's the data I'm entering (it's not very original): Registering Agent: Admin Agent Writing Number: A1234 Phone: 123-456-7890 E-mail: admin@nightslyr.com Regional Sales Coordinator: Another Person District Sales Coordinator: Someone Else Hidden values: Event ID: 24 User ID: 1 The queries that are echoing to the screen: SELECT * FROM fusion_aflac WHERE ev_id='24' AND user_id='1' UPDATE fusion_aflac SET registering_agent='Admin', agent_writing_number='A1234', phone='123-456-7890', email='admin@nightslyr.com', regional_sales_coordinator='Another Person', district_sales_coordinator='Someone Else', ev_title='Registration test', ev_start='2007-07-02 09:30:00', ev_end='2007-07-02 09:30:00', login_timestamp='1183402221', login_status='1' WHERE ev_id='24' AND user_id='1' UPDATE fusion_aw_ec_events SET ev_allow_logins='1' WHERE ev_id='24' SELECT * FROM fusion_aw_ec_logins WHERE ev_id='24' AND user_id='1' UPDATE fusion_aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='1183402221' WHERE ev_id='24' AND user_id='1' The ones I've put in bold should be INSERT queries. And for the life of me I can't see why it's defaulting to UPDATE...SET. Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288248 Share on other sites More sharing options...
AndyB Posted July 2, 2007 Share Posted July 2, 2007 mysql_query() should return false on an empty result, correct? Nope. mysql_query() returns a resource on success, or FALSE on error. Source: http://ca.php.net/manual/en/function.mysql-query.php Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288250 Share on other sites More sharing options...
KevinM1 Posted July 2, 2007 Author Share Posted July 2, 2007 mysql_query() should return false on an empty result, correct? Nope. mysql_query() returns a resource on success, or FALSE on error. Source: http://ca.php.net/manual/en/function.mysql-query.php Awesome! That was just what I needed. Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/58074-solved-database-problem-or-is-it-my-script/#findComment-288253 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.