JREAM Posted May 12, 2009 Share Posted May 12, 2009 I got tihs right, and it outputs all the posts in the export() function, ie some random text: title - sdfasdf, desc - asdfasfd $jTitle = clean($_POST['title']); $jDesc = clean($_POST['desc']); $jPrice = clean($_POST['price']); $jProg = clean($_POST['progress']); $jPri = clean($_POST['priority']); $jAC = clean($_POST['assign_client']); $jDateDue = clean($_POST['date_due']); $jDateMod = dateTime; echo extract($_POST); foreach($_POST as $key =>$val) { echo $key . ' - ' . $val . '<br />'; } $sql = mysql_query("INSERT INTO $sqlcol SET `title`='$jTitle', `desc`='$jDesc', `price`='$jPrice', `progress`='$jProg', `priority`='$jPri', `assign_client`='$jAC', `date_due`='$jDateDue', `date_modified`='$jDateMod'"); if($sql) {$status = 'Project Created!';} The Data gets inserted into the Database but its blank. If I force a MySQL Error and remove the ` ` ticks, it prints: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc='', price='', progress='', priority='', assign_client='', ' at line 3 Which shows me the posts arent being placed into that statement. Otherwise I get the 'Project Created!' message when I put the `` ticks back. All clean() does is: function clean($str) {mysql_real_escape_string($str);} Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/ Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 Your SQL is wrong... INSERT INTO table() VALUES(); You are using INSERT with UPDATE commands... Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832757 Share on other sites More sharing options...
JREAM Posted May 12, 2009 Author Share Posted May 12, 2009 Even if I do: $sql = mysql_query("INSERT INTO $sqlcol (`title`, `desc`, `price`, `progress`, `priority`, `assign_client`, `date_due`, `date_modified`) VALUES('$jTitle', '$jDesc', '$jPrice', '$jProg', '$jPri', '$jAC', '$jDateDue', '$jDateMod') "); I get no MySQL error but the fields are blank, I am checking everything I think its something really small And thank you for such a quick reply :) ps: I use backticks since i have a column named 'desc' which is a reserved word i think Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832764 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Your clean() function isn't returning anything. Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832766 Share on other sites More sharing options...
JREAM Posted May 12, 2009 Author Share Posted May 12, 2009 Yes it was my function! Thank you gosh.. stuck on it for 3 days im a newblette Cheers!! return $str; Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832769 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Depends. function clean($str) { return mysql_real_escape_string($str); } Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832770 Share on other sites More sharing options...
JREAM Posted May 12, 2009 Author Share Posted May 12, 2009 Oh nice i like saving space = Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832771 Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 Yes it was my function! Thank you gosh.. stuck on it for 3 days im a newblette Cheers!! return $str; You can use that syntax, please see the MySQL Manual - INSERT. We need to see the clean() function because it looks like you're inserting empty stings into all of your columns. EDIT, nvm. Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832775 Share on other sites More sharing options...
JREAM Posted May 12, 2009 Author Share Posted May 12, 2009 Okay cool, it appears you can use INSERT SET as well Link to comment https://forums.phpfreaks.com/topic/157876-solved-is-there-something-wrong-with-this-mysql-query-i-cant-get-the-posts-in-it/#findComment-832784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.