Re: Insert query error
| From: | Gavin Chalkley | Date: | Sat, 06 Aug 2011 08:29:09 +0000 |
| Subject: | Re: Insert query error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-47952@lists.php.net to get a copy of this message | ||
Chris,
Why not escape, and extract the data prior to Insert string?
On 06/08/2011 05:41, Chris Stinemetz wrote:
I am getting the following error trying to run the below query. Any suggestions on what I am doing wrong? Thank you, Something went wrong while inserting your store visitCannot add or update a child row: a foreign key constraint fails (store.posts, CONSTRAINTposts_ibfk_1FOREIGN KEY (post_store) REFERENCESstores(store_id) ON DELETE CASCADE ON UPDATE CASCADE) $sql = "INSERT INTO posts(market, type, post_store, post_tptest, post_content, post_by, post_date) VALUES('" . mysql_real_escape_string($_POST['market']) . "', '" . mysql_real_escape_string($_POST['type']) . "', '" . mysql_real_escape_string($_POST['post_store']) . "', '" . sha1($_POST['post_tptest']) . "', '" . mysql_real_escape_string($_POST['post_content']) . "', " . $_SESSION['user_id'] . ",NOW())";