PHP - While Looped Insert Is Not Working As Expected. No Errors.
I cannot get this INSERT to work. Not records are being added to the sys_city_dev table. No query errors are being thrown.
I am simply trying to add ALL records from all_illinois to sys_city_dev and Mid should have be add as 11 in all inserts. city_name of course will be field city_name from all_illinois. Here is my code: $query = "SELECT * FROM all_illinois"; if ($results = mysqli_query($cxn, $query)) { $row_cnt = mysqli_num_rows($results); echo $row_cnt . " Total Records in Query.<br /><br />"; if (mysqli_num_rows($results)) { while ($rows = mysqli_fetch_array($results)) { echo $rows['city_name'] . "<br />"; $mid_id = '11'; $insert_city_query = "INSERT INTO sys_city_dev (ID, Mid, cityName, forder, disdplay, cid) VALUES (' ','" . $mid_id . "','" . $rows['city_name'] . "', '', '','')"; if (!$insert_city_query) exit(mysql_error()); } } } Here is my insert table structure and 5 records dump: -- -- Table structure for table `sys_city_dev` -- CREATE TABLE IF NOT EXISTS `sys_city_dev` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev` -- INSERT INTO `sys_city_dev` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'Dothan', 0, 0, 0), (84011, 1, 'Alabaster', 0, 0, 0), (84012, 1, 'Birmingham', 0, 0, 0), (84013, 2, 'Flagstaff', 0, 0, 0), (84014, 1, 'Auburn', 0, 0, 0); And the all_illinois dump w/ 5 records: -- -- Table structure for table `all_illinois` -- CREATE TABLE IF NOT EXISTS `all_illinois` ( `state_id` varchar(255) NOT NULL, `city_name` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `all_illinois` -- INSERT INTO `all_illinois` (`state_id`, `city_name`) VALUES ('135', 'Abingdon'), ('135', 'Adair'), ('135', 'Addieville'), ('135', 'Addison'), ('135', 'Adrian'); Similar TutorialsI'm using PHP 5.2.14 under Windows XP. I'm trying to use ini_set to turn on the 'track_error' configuration option, and it's not working. I make this call, $xxx = ini_set('track_error',"1"); and it returns false. According to the documentation, track_error can be set from any source (including ini_set). What could prevent that from happening? Going back one step, I want to set track_errors so that I can fetch and process the error which occurs when mysql_connect fails. Since it fails, it returns no link, making it impossible to call mysql_errors. Whether ini_set can be made to work or not, is there another, perhaps better way to accomplish this? Hello I want to check that a variable the user enters is not empty and that it is a string (no numbers). Here is what i have written: Code: [Select] <?php include('css/layout.css.php'); include('css/menu.css'); if (isset($_POST['submit'])) { include('includes/dbconn.php'); if (is_string($_POST['name']) && strlen($_POST['name']) > 0) { $name = mysql_real_escape_string($_POST['name']); } else { echo "Category name must be a word!<br />"; } if (isset($name)) { echo $name; } else { echo "something"; } } ?> and this is the form i'm getting the data from: Code: [Select] <form action="category_add.php" method="post"> <table class="table-view"> <tr> <td><label for="name">Category Name</label></td> <td><input type="text" name="name" id="name"></td> </tr> <tr> <td><input type="submit" value="Save changes" name="submit" id="submit"></td> </tr> </table> </form> If i enter nothing it works fine, if i enter a string it also works fine, the problem is when i enter 123 in the textbox, i dont get the "Category name must be a word!" as i expected i would. Could someone help me with this one please? Thanks in advance. I am doing some study on using time() and date() and i just wrote this simple for loop to add one day to each iteration with +$i and its echoing the unix timestamp as opposed to the correctly formated date as it should be based on my code. Anyone have any idea why this is not working as expected? for($i=0; $i < 50; $i++) { echo $time = time()+$i . "<br />"; // add a day on each iteration echo date('y-m-d', $time) . "<br />"; // should echo 10-12-02, 10-12-03, 10-12-04, etc.. } what am i doing wrong here? arrgggg! maybe its too late for this s$%^#! Hello, Currently have an array like looks like the following when using print_r($session->items): Array ( [F1225] => 1 [EDS11147317] => 1 [1156D6RE001] => 1 [I111ADE47946] => 1 [S679AQ339] => 1 [S67914599] => 1 [CH111337631254] => 1 [S6787903647] => 1 [A11144O189] => 1 [F11144520] => 1 [121584Q12] => 1 [I11144661ADE] => 1 [S678829NB] => 1 ) I am trying to check if an item is in the array and if so, display a different result but currently every item says it is in the array when they are not (unless my logic is off...from the items I am looking at some should be included and some should not..but the below code is showing every item as having the same result). Example: foreach ($items as $item) { if (in_array($item->ItemID, $session->items)) { //$session->items is the array output above echo "In Array"; } else { echo "NOT in Array"; } } Currently everything say "In Array" when some should not. Am I using the in_array incorrectly? Thanks Everyone. Good morning! I've spent hours on this to no avail. My understanding is that unset() only deletes the copy of the variable local to the current scope. But I am getting a very different result. I have the following structure and output. What am I doing wrong? <?php first_function(); second_function() { for ($count = 0; $count < $max; $count++) { $my_array = array[]; //initialize my array, local in this scope but can be called global in nested functions print_r($my_array ); //print 1: array should be always empty but is only in empty in FIRST loop. third_function(); //fills the array with numbers, see below, nested function declaring a global array print_r($my_array ); //print 3 of my_array, should be full of numbers from third_function global changes unset($my_array); //delete my array so I can start with new array in next loop print_r($my_array ); //print 4 of my_array, should be unknown variable print('End one loop'); } } third_function() { global $my_array; //declare my global variable //...fill my now global array with stuff... print_r($my_array ); //print 2: should be filled with numbers. And it is. } ?> My output amazingly looks something like this Array() Array(45,48,38...all my numbers...) Array() ERROR: Notice -- Undefined variable: my_array End one loop Array(45,48,38...all my SAME numbers again as if array was NOT unset...) ...... The first and second print lines make sense. But shouldn't the third line be the array filled with numbers generated in third_function? The fourth line error makes sense as the variable is unset. But WHAT did I unset? The next time around in the loop, the array contains the SAME numbers from the previous loop and my new numbers simply get appended to the end of the ever growing array. Why? This should not be that difficult but seems to be driving me crazy. Any help would be greatly appreciated. alexander When submitting the form, the records are sometimes inserted and sometimes not. I receive no errors stating what the problem is. Code: [Select] <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO customer_tbl (customer_first_name, customer_last_name, customer_company, customer_ac, customer_phone, customer_fax_ac, customer_fax_phone, customer_email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['customer_first_name'], "text"), GetSQLValueString($_POST['customer_last_name'], "text"), GetSQLValueString($_POST['customer_company'], "text"), GetSQLValueString($_POST['customer_ac'], "text"), GetSQLValueString($_POST['customer_phone'], "text"), GetSQLValueString($_POST['customer_fax_ac'], "text"), GetSQLValueString($_POST['customer_fax_phone'], "text"), GetSQLValueString($_POST['customer_email'], "text")); $customer_id = false; if(mysql_query($insertSQL, $connCid)) $customer_id = mysql_insert_id(); else echo "There was an error."; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO quote_request_tbl (customer_id, quote_trans_date, quote_from_company, quote_from_address, quote_from_city, quote_from_state, quote_from_zip, quote_to_company, quote_to_address, quote_to_city, quote_to_state, quote_to_zip, quote_comments) VALUES ('$customer_id', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['quote_trans_date'], "text"), GetSQLValueString($_POST['quote_from_company'], "text"), GetSQLValueString($_POST['quote_from_address'], "text"), GetSQLValueString($_POST['quote_from_city'], "text"), GetSQLValueString($_POST['quote_from_state'], "text"), GetSQLValueString($_POST['quote_from_zip'], "text"), GetSQLValueString($_POST['quote_to_company'], "text"), GetSQLValueString($_POST['quote_to_address'], "text"), GetSQLValueString($_POST['quote_to_city'], "text"), GetSQLValueString($_POST['quote_to_state'], "text"), GetSQLValueString($_POST['quote_to_zip'], "text"), GetSQLValueString($_POST['quote_comments'], "text")); $quote_id = false; if(mysql_query($insertSQL, $connCid)) $quote_id = mysql_insert_id(); else echo "There was an error."; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") && (isset($quote_id))) { $insertSQL = sprintf("INSERT INTO building_tbl (quote_id, building_quantity, building_width, building_length, building_height, building_overhang, slope_id, building_type_id, manufacture_id, foundation_id) VALUES ('$quote_id', %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['building_quantity1'], "int"), GetSQLValueString($_POST['building_width1'], "int"), GetSQLValueString($_POST['building_length1'], "int"), GetSQLValueString($_POST['building_height1'], "int"), GetSQLValueString($_POST['building_overhang1'], "int"), GetSQLValueString($_POST['slope_id1'], "int"), GetSQLValueString($_POST['building_type_id1'], "int"), GetSQLValueString($_POST['manufacture_id1'], "int"), GetSQLValueString($_POST['foundation_id1'], "int"); mysql_select_db($database_connCid, $connCid); $Result1 = mysql_query($insertSQL, $connCid) or die(mysql_error()); header('Location: index.php?view=article&id=7'); } mysql_select_db($database_connCid, $connCid); $query_rsSlope = "SELECT * FROM slope_tbl ORDER BY slope_id ASC"; $rsSlope = mysql_query($query_rsSlope, $connCid) or die(mysql_error()); $row_rsSlope = mysql_fetch_assoc($rsSlope); $totalRows_rsSlope = mysql_num_rows($rsSlope); $query_rsSlope = "SELECT * FROM slope_tbl ORDER BY slope_id ASC"; $rsSlope = mysql_query($query_rsSlope, $connCid) or die(mysql_error()); $row_rsSlope = mysql_fetch_assoc($rsSlope); $totalRows_rsSlope = mysql_num_rows($rsSlope); mysql_select_db($database_connCid, $connCid); $query_rsBuildingType = "SELECT * FROM building_type_tbl ORDER BY building_type_id ASC"; $rsBuildingType = mysql_query($query_rsBuildingType, $connCid) or die(mysql_error()); $row_rsBuildingType = mysql_fetch_assoc($rsBuildingType); $totalRows_rsBuildingType = mysql_num_rows($rsBuildingType); mysql_select_db($database_connCid, $connCid); $query_rsManufacture = "SELECT * FROM manufacture_tbl ORDER BY manufacture_name ASC"; $rsManufacture = mysql_query($query_rsManufacture, $connCid) or die(mysql_error()); $row_rsManufacture = mysql_fetch_assoc($rsManufacture); $totalRows_rsManufacture = mysql_num_rows($rsManufacture); mysql_select_db($database_connCid, $connCid); $query_rsFoundation = "SELECT * FROM foundation_tbl ORDER BY foundation_name ASC"; $rsFoundation = mysql_query($query_rsFoundation, $connCid) or die(mysql_error()); $row_rsFoundation = mysql_fetch_assoc($rsFoundation); $totalRows_rsFoundation = mysql_num_rows($rsFoundation); ?> I belve the problem is in this part of the code: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") && (isset($quote_id))) Many thanks in advance. Hi, I"m trying to create insert images files name into the database and save images in folder, however, after i created databse connection, and excuted it... I'm getting error message said Parse error: syntax error, unexpected $end in C:\xampp\htdocs\ourdeaf\uploadimages\upload.php on line 76 That line 76 is at end of code after </html>, what went wrong! Code: [Select] <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" ENCTYPE="multipart/form-data"> Upload:<br><br> <input type="file" name="image"><br><br> <input type="hidden" name="uploaded" value="1"> <input type="submit" value="Upload"> </form> <? }else{ //if the form hasn't been submitted then: //from here onwards, we are copying the file to the directory you made earlier, so it can then be moved //into the database. The image is named after the persons IP address until it gets moved into the database //get users IP $ip=$REMOTE_ADDR; //don't continue if an image hasn't been uploaded if (!empty($image)){ //copy the image to directory copy($image, "./temporary/".$ip.""); //open the copied image, ready to encode into text to go into the database $filename1 = "./temporary/".$REMOTE_ADDR; $fp1 = fopen($filename1, "r"); //record the image contents into a variable $contents1 = fread($fp1, filesize($filename1)); //close the file fclose($fp1); //encode the image into text $encoded = chunk_split(base64_encode($contents1)); //insert information into the database mysql_query("INSERT INTO images (img,data)"."VALUES ('NULL', '$encoded')"); //delete the temporary file we made unlink($filename1); } //end } ?> I have a problem where I am getting these errors after a form has been submitted from join.html Here are the errors: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Here is the insert.php file http://pastebin.com/EVtgidQC And the join.html file - http://pastebin.com/hqDtGLe5 How would I fix those errors - I got the code from http://forum.hey0.net/showthread.php?tid=2509 The form is at scswc.com/join.html if you want to look at it. I really want to get this working so if you need any more info to help fix it just ask thanks! I have a form with a series of text boxes where the User enters specific data, be it text, numeric, or date/time. It is not mandatory to fill in every box, but when I submit the form to be put into a mysql table, I get errors such as "Incorrect time value: '' for column 'starttime' at row 1" "Incorrect decimal value: '' for column 'workkj' at row 1" How can I setup the mysql table to accept blank answers? Or is there something I need to do in php to fix this? Sorry if this is simple... I'm still learning. Thanks for the help! Excuse my late night slop! But I read a thread earlier and I am working on a dynamic way to address checkboxes with some intuitive messages while processing, and I cannot get this to work right w/out errors.. Any ideas where I am going totally wrong with this? <form name="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> One <input type="checkbox" name="checkbox[]" value="checkOneValue" /><br /> Two <input type="checkbox" name="checkbox[]" value="checkTwoValue" /><br /> Three <input type="checkbox" name="checkbox[]" value="checkThreeValue" /><br /> Four <input type="checkbox" name="checkbox[]" value="checkFourValue" /><br /> Five <input type="checkbox" name="checkbox[]" value="checkFiveValue" /><br /> <input type="submit" name="submit" value="Echo Checkbox Data!" /> </form> <?php if (isset($_POST['submit'])) { $checkbox = $_POST['checkbox']; foreach ($checkbox as $checkboxValue) if (empty($checkboxValue)) { echo "$checkboxValue is emtpy"; } else { echo "<br>$checkboxValue is checked"; } }; ?> When no checkboxes are selected, I am dealing with this S%#$! Otherwise it works as intended.. Notice: Undefined index: checkbox in C:\wamp\www\php_practice\0\checkbox_echoing_1.php on line 24 Warning: Invalid argument supplied for foreach() in C:\wamp\www\php_practice\0\checkbox_echoing_1.php on line 26 I'm trying to figure out how to add up all the $qty_total that exist into an overall total. I hope I'm not oversimplifying my example.. I have this: $qty_total = $qty_insert * $d['workshop_price']; $qty_insert loops several times and I want: $overall_total = $qty_total + qty_total + ...however many.. Hi, I want to loop out data from DB in <input> and change and update several posts at the same time. Can you give me a short example, how <input> and maybe foreach could look like? Thanks Hello, I'm going to be sending emails to users from a community calendar showing events for the day or a time frame specified elsewhere. The problem I'm having is turning results of DB query into a string when there are multiple results for the day. It works just fine with single results. I understand why it doesn't work but can't figure out how to solve the problem. Don't worry about the $eventdate as that comes from the same array as the $event_id used to call the array shown below. I tried foreach and implode but couldn't get it working so I'm starting over and asking for your guidance on how is the best way to pull this off. Thanks for your help. Code: [Select] $getevent = mysql_query("SELECT title, description from ".$conf['tbl']['events']." WHERE event_id=$event_id AND private=0"); WHILE ($gtevent = mysql_fetch_array($getevent)) { $event_title=$gtevent['title']; $event_description=$gtevent['description']; $message="<p><span style=\"font-size:24px\">$event_title</span><br />$eventdate</p><p>$event_description</p>"; } I have this function, but it doesnt work. Basically the list outputs a list of news features, and puts a line under neath each article to seperate them. However once the last article has been reached, I don't want the break to be shown. this is my code, any help would be appreciated as i am really struggling on this. Just need to determine the last item in the array, and stop the <hr split> from being output. function newsFeature(){ $event = "SELECT imgname, title, content, pkID from news ORDER BY date, time DESC LIMIT 5"; $event_page = query($event); $count = numRows($event_page); while ($row = mysql_fetch_assoc($event_page)) { $rowcount = $count; $para = substr($row['content'] , 0,100); $result .= '<article>'; $result .= '<a href="news-article.php?pkID=' . $row['pkID'] . '"><img src="uploads/thumbs/' . $row['imgname'] . '" alt="" width=116 height=83/ ></a>'; $result .= '<h2><a href="news-article.php?pkID=' . $row['pkID'] . '">' . $row['title'] . '</a></h2>'; $result .= '<p>' . $para . '...</p>'; $result .= '<p><a class="read-more" href="news-article.php?pkID=' . $row['pkID'] . '">Read more<span></span></a></p>'; $result .= '</article>'; if($row != end($row[])){ $result .= '<hr class="split">'; } } return $result; } Hi all, Im really struggling to build an update multiple records form, Ive built my table which calls all data i need from the db in a looped region which works fine I just cant understand how to then input these back into the table in the correct rows, if this makes sense? Ive been reading this tutorial but Its not very informative its more of a copy and paste http://www.phpeasystep.com/mysql/10.html EvilSpider 123456 FakeEmail@yahoo.com Connected successfullyYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@yahoo.com)' at line 2 mysql_query("INSERT INTO user (username, password,email) VALUES($user, $pass, $email) ") and when i dont do the @ sign i still get the error EvilSpider 123456 FakeEmail Connected successfully Unknown column 'EvilSpider' in 'field list' Hello PHP freaks. Having a few issues with my PHP scripts, specifically the $query = sprintf and mysql_real_escape_string functions. Kind of new to this, so if you do reply, explain it to me like I am a complete moron... Oh, before I forget. My specific problem is that I can click the "Post" button and follow the header to "Location: view.php", but the actual text in the Subject and Message fields is not being sent to the database. Finally managed to get rid of all the error messages I was getting, and now I get this... Thanks in advance! Here is my script for the entire page: _________________________________________________ ____________ <?php require_once('auth.php'); ?> <?php mysql_connect('xxxxxx', 'xxxxxx', 'xxxxxx'); $subject = $_POST['subject']; $message_text = $_POST['message_text']; // add entry to the databse if the form was submitted and // the necessary information was supplied in the form if (isset($_POST['submitted']) && $subject && $message_text) { $query = sprintf('INSERT INTO FORUM_MESSAGE (SUBJECT, MSG_TEXT) VALUES ($subject, $message_text)', Ryan_iframe, mysql_real_escape_string($subject), mysql_real_escape_string($message_text)); mysql_query($query); // redirect user to list of forums after new record has been stored header('Location: view.php'); } // form was submitted but not all the information was correctly filled in else if (isset($_POST['submitted'])) { $message = '<p>Not all information was provided. Please correct ' . 'and resubmit.</p>'; } ?> <!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=iso-8859-1" /> <title>Member Index</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1> Home | <a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a> <br /><br /> <form method="post"> <div> <label for="subject">Subject: </label> <input type="text" id="subject" name="subject" value="<?php echo htmlspecialchars($subject); ?>" /><br /> <label for="message_text">Message: </label> <input type="text" id="message_text" name="message_text" value="<?php echo htmlspecialchars($message_text); ?>" /><br /> <input type="hidden" name="submitted" value="true" /> <input type="submit" value="Post" /> </div> </form> </body> </html> I am trying to do an INSERT on my "bio_answer" table which is a junction table in between the "member" and "bio_question" tables. My PHP just tries to do the INSERT into "bio_answer" and doesn't touch the parent tables, which I assume is okay?! Here is a snippet of my code... if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). // Initialize Errors Array. $errors = array(); // Trim all form data. $trimmed = array_map('trim', $_POST); // ************************ // Validate Form Data. * // ************************ // Validate Answer1. if (strlen($trimmed['answer01']) >= 2 && strlen($trimmed['answer01']) <= 1024){ // Valid Answer1. $answerArray[0] = $trimmed['answer01']; $questionID = 1; echo '<p>$memberID = ' . $memberID . '</p>'; // Resolves to 19 which exists in the "member" table echo '<p>$questionID = ' . $questionID . '</p>'; // Resolves to 1 which exists in the "bio_question" table echo '<p>$answerArray[0] = ' . $answerArray[0] . '</p>'; // Resolves to whatever I type in my form, e.g. "This is a test..." }else{ // Invalid Answer1. $errors['question01'] = 'Answer must be 2-1024 characters.'; }//End of VALIDATE ANSWER1 // ****************************** // Attempt to Create Thoughts. * // ****************************** if (empty($errors)){ // Valid form data. // Build query. $q1 = "INSERT INTO bio_answer(member_id, question_id, response, created_on) VALUES(?, ?, ?, NOW())"; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variables to query. mysqli_stmt_bind_param($stmt1, 'iis', $memberID, $questionID, $answerArray[0]); // Execute query. mysqli_stmt_execute($stmt1); // Verify Insert. if (mysqli_stmt_affected_rows($stmt1)==1){ // Insert Succeeded. $_SESSION['resultsCode'] = 'THOUGHTS_NEW_THOUGHTS_CREATED_2138'; }else{ // Insert Failed. $_SESSION['resultsCode'] = 'THOUGHTS_NEW_THOUGHTS_FAILED_2139'; }//End of UPDATE MEMBER RECORD // Close prepared statement. mysqli_stmt_close($stmt1); // Set Error Source. $_SESSION['errorPage'] = $_SERVER['SCRIPT_NAME']; // Redirect to Display Outcome. header("Location: " . BASE_URL . "/members/results.php"); // End script. exit(); }//End of ATTEMPT TO CREATE THOUGHTS My script keeps failing and errors to 'THOUGHTS_NEW_THOUGHTS_FAILED_2139' What is wrong with my Script/SQL?? Thanks, Debbie hello, i am returning the error in the following code. im i doing something wrong? Code: [Select] { $sql = "UPDATE jobs SET contact = ' . mysql_real_escape_string{$_POST['contact']} .', contactphone = ' . mysql_real_escape_string{$_POST['contactphone']} .', customer = ' . mysql_real_escape_string{$_POST['customer']} .', initial = ' . mysql_real_escape_string{$_POST['initial']} .', address = ' . mysql_real_escape_string{$_POST['address']} .', city = ' . mysql_real_escape_string{$_POST['city']} .', postal = ' . mysql_real_escape_string{$_POST['postal']} .', province = ' . mysql_real_escape_string{$_POST['province']} .', description = ' . mysql_real_escape_string{$_POST['description']} .', mechanic = ' . mysql_real_escape_string{$_POST['mechanic']} .', ponumber = ' . mysql_real_escape_string{$_POST['ponumber']} .', status = ' . mysql_real_escape_string{$_POST['status']} .' WHERE id = '$id"; $result = mysql_query($sql) or die('Error, updating job failed. Check you fields and try again.'); echo "<center> You have successfully updated the new job. You can see your changes below."; } I have a mysql insert statement generated with php that is not populating the table. I've echoed the statement and if I copy and paste into phpmyadmin it works fine. The result of the mysql_query function is true. I've emptied the table so there are no primary key conflicts. I've put the statement in a try catch and it does not display a exception. What else can I try? Here's the statement INSERT INTO `wp_term_relationships` (object_id, term_taxonomy_id, term_order) VALUES (1597,83,0) Works absolute fine if I copy and paste into phpmyadmin. Does not populated the table if run through mysql_query |