acctman Posted May 4, 2012 Share Posted May 4, 2012 I'm not getting any errors but its also not INSERTing into the database. Without an error I can figure out whats wrong. $db_server = 'localhost'; $db_user = 'user_db'; $db_pass = 'password'; $dbc = mysql_connect ($db_server, $db_user, $db_pass); if (!$dbc) { die(mysql_error()); header ('Location: /form'); exit; } if (is_array($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string(stripslashes($value)); } } $xRequestType = $_POST["xRequestType"]; $xConsumerBusiness = $_POST["xConsumerBusiness"]; $xGlobalLocation = $_POST["xGlobalLocation"]; $xFirstName = strtolower(str_replace("'","''",$_POST["xFirstName"])); $xFirstName = strtoupper(substr($xFirstName,0,1)).substr($xFirstName,1); $xLastName = strtolower(str_replace("'","''",$_POST["xLastName"])); $xLastName = strtoupper(substr($xLastName,0,1)).substr($xLastName,1); $xEmail = strtolower(str_replace("'","''",$_POST["xEmail"])); $xTitle = strtolower(str_replace("'","''",$_POST["xTitle"])); function dbSet($fields, $source = array()) { $set=''; if (!source) $source = &$_POST; foreach ($fields as $field) { if (isset($source[$field])) { $set.="`$field`='".mysql_real_escape_string($source[$field])."', "; } } return substr($set, 0, -2); } // INSERT INTO DATABASE mysql_select_db("new_contact",$dbc) or die("Could not select new_contact"); $fields = explode(" ", "xRequestType xConsumerBusiness xGlobalLocation xFirstName xLastName xEmail xTitle xCompany xAddress xCity xState xZip xPhone xFax xProductDesc xComment"); $query = "INSERT INTO new_contact SET ".dbSet($fields, $_POST); mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/262067-possible-explode-andor-function-problem/ Share on other sites More sharing options...
MMDE Posted May 4, 2012 Share Posted May 4, 2012 At the start of the file: error_reporting(E_ALL); And replace: mysql_query($query); with: echo $query; mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/262067-possible-explode-andor-function-problem/#findComment-1342998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.