relation "apps" does not exist in heroku when trying to create a table

This is the query

[php]$sql = “CREATE TABLE IF NOT EXISTS apps (
id int(11) unsigned NOT NULL auto_increment,
name varchar(100) NOT NULL default ‘’,
description varchar(5000) NOT NULL default ‘’,
link varchar(200) NOT NULL default ‘’,
README text(50000) NOT NULL,
PRIMARY KEY (id)
);”;

pg_query($con,$sql);[/php]

This is what I’m getting

Warning: pg_query(): Query failed: ERROR: syntax error at or near "" LINE 1: CREATE TABLEapps` ( ^ in /app/www/submit.php on line 22 Warning: pg_query_params(): Query failed: ERROR: relation “apps” does not exist

I find it weird that it complains about a table not existing when trying to create it. Is this a problem with heroku? I’d test it locally but my XAMPP Apache is not working.

To be honest I think you have you are using the wrong single quotes and that’s causing your issue…

[php]$sql = “CREATE TABLE IF NOT EXISTS ‘apps’ (
‘id’ int(11) unsigned NOT NULL auto_increment,
‘name’ varchar(100) NOT NULL default ‘’,
‘description’ varchar(5000) NOT NULL default ‘’,
‘link’ varchar(200) NOT NULL default ‘’,
‘README’ text(50000) NOT NULL,
PRIMARY KEY (‘id’)
);”;[/php]

And to be honest you don’t even need them, because your column names don’t contain spaces.

[php]$sql = “CREATE TABLE IF NOT EXISTS apps (
id int(11) unsigned NOT NULL auto_increment,
name varchar(100) NOT NULL default ‘’,
description varchar(5000) NOT NULL default ‘’,
link varchar(200) NOT NULL default ‘’,
README text(50000) NOT NULL,
PRIMARY KEY (id)
);”;[/php]

he only thing I can think of is that maybe you have auto committing turned off… and you have to run the


oamir

Sponsor our Newsletter | Privacy Policy | Terms of Service