I hope somebody's out there surfing these forums who's bored to death because I have a short query string that keeps giving me errors, and I don't know if it's just that I've been staring at it too long and my eyes are glazing over the obvious faux-pas or that I'm just not paying close enough attention, but it's about to make me pull my hair out! Hope someone sees the mistake right away!
🙂
$sections = mysql_query("CREATE TABLE sections (
unique_id mediumint(10) unsigned PRIMARY KEY AUTO_INCREMENT,referrer mediumint(10) unsigned,priority mediumint(10) unsigned,active enum('YES','NO'),section varchar(75),category varchar(50),class varchar(50),topic varchar(25),subtopic varchar(25),date date,title varchar(100),keywords varchar(255),description varchar(255),stylesheet varchar(25),tagline varchar(255),caption varchar(100),intro varchar(255),body text,url varchar(100),resource varchar(255),publication varchar(50),editor varchar(25),amount decimal(8,2),fname varchar(25),lname varchar(25),position varchar(100),company varchar(100),address1 varchar(50),address2 varchar(50),postal mediumint(10) unsigned,country varchar(50),phone mediumint(25) unsigned,email varchar(100),list varchar(100),$link");
$schema = mysql_query($sections,$link);
if ($schema)
{
echo "Database Schema Created";
}
elseif (!$schema)
{
echo mysql_errno().": ". mysql_error ()."";
return 0;
}
I'm getting the error at the first column name of the table creation (unique_id). It doesn't seem to like something I've used in the part of the query string that creates the table's columns.
I've input this create table query in the command line terminal, and it works fine. It must be an error where I'm forgetting to escape something that PHP doesn't understand...because MySQL understands the query perfectly.
I've also tried other variations of ' and " and such, and I also tried ",$link); in place of ,$link");
I also tried separating out the create table query string into a separate variable that I could plug in its place immediately before ,$link because I thought it would make finding quotation errors easier for me - that didn't work either.
Finally, after making my way through a bunch of different errors I got each time I changed something, here's what it finally gave me after the portion of my script immediately preceding this part successfully does everything clear up to selecting the database in which to perform this query:
1065: Query was empty
I know, it's probably a really obvious oversight...but, that's what everyone's here for, right? 🙂
Maybe I should do the following instead?
$schema = mysql_query($sections,$link);
...and place the create table string all by itself in $sections ???
I could have sworn that's what I did in the first place, but maybe I missed a quote or something....
Anyway, any help would be greatly appreciated.
Thanks,
Crystal