Jump to content

[SOLVED] Is there something wrong with this MySQL Query? I cant get the posts in it!


Recommended Posts

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);}

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.