Jump to content

SQL Query not working


benjy355

Recommended Posts

A query I'm using is returning no errors and no database update!

$qtxt = "INSERT INTO site_uploads (uid, title, desc, file, uploaded) VALUES ('" . $UserID . "', '" . $Data[1] . "', '" . $Data[2] . "', '" . $_FILES['uploaded']['name'] . "', '" . date("Y-m-d") . "')";mysql_query($qtxt) or CreateError("Could not query database: " . mysql_error());

Anybody know why this is happening? runaway.gifAfter I printed the query this was basically what came up: (no errors I can see)

INSERT INTO site_uploads (uid, title, desc, file, uploaded) VALUES ('1', 'Notepad 2', 'Try it!', 'Notepad 2.zip', '2006-08-03')

Link to comment
Share on other sites

What does CreateError do? Maybe just print mysql_error() regardless of what happens, and see if it ever shows anything.
CreateError(); is a function I made for posting errors without stopping everything and ruining the page >_>The database structure is: (phpMyAdmin ftw!)uploads_database.jpg
Link to comment
Share on other sites

Mmkay...

MySQL said:#1064 - 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, file, uploaded) VALUES ('1', 'Notepad 2', 'It rocks your s
Link to comment
Share on other sites

I don't know how it is on your server, but the one I use requires syntax using ` surrounding the table name and fields, like this:

INSERT INTO `site_uploads` (`uid`, `title`, `desc`, `file`, `uploaded`) VALUES ('1', 'Notepad 2', 'Try it!', 'Notepad 2.zip', '2006-08-03')

Link to comment
Share on other sites

Typically backquotes aren't required, but they can be used for clarification. For example, since "date" is a reserved SQL word, if you have a column named "date" you need to surround it with backquotes when you refer to it.

$me =& new SixPack();
You have turned yourself into a sixpack, dude!
Link to comment
Share on other sites

I think of =& as buy in this case btw. My beer drinking class is a work in progress. :)
I don't think that PHP5 supports operator overloading, lol. But while we're at it:
foreach($internet as $website){  if($website->doesSuck(array('standards', 'coding', 'content', 'design'))  {	self::optimize(website);	self::sendInvoice(website);	self::addToResume(website);  }}$income = self::getDisposableIncome();spend($income, array('videogames', 'computerstuff', 'ninjagear');self::increment1337();

:)

Link to comment
Share on other sites

I don't think that PHP5 supports operator overloading, lol. But while we're at it:
foreach($internet as $website){  if($website->doesSuck(array('standards', 'coding', 'content', 'design'))  {	self::optimize(website);	self::sendInvoice(website);	self::addToResume(website);  }}$income = self::getDisposableIncome();spend($income, array('videogames', 'computerstuff', 'ninjagear');self::increment1337();

:)

Hehehe,spend($income, array('videogames', 'computerstuff', 'ninjagear');PHP would return "Unexpected ';' expecting ')' on line 11 of omfglolwtfbbq.php"
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...