Re: mysql_db_query create table error

From: Date: Wed, 12 Sep 2001 00:38:24 +0000
Subject: Re: mysql_db_query create table error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66974@lists.php.net to get a copy of this message
On Wed, 12 Sep 2001 01:19, mkrisher wrote: > All, > > I am trying to create a table in a mySQL database, seems like it would > be easy enough, but for some reason it is not working, below is the > code: > > // Query to create table and columns > $sql = "CREATE TABLE 'products' ( > id INTEGER UNSIGNED NOT NULL AUTOINCREMENT PRIMARY KEY, > description TEXT, > jewelery-type VARCHAR(255), > catalog-number VARCHAR(255), > price VARCHAR(255), > stone-type VARCHAR(255), > stone-color VARCHAR(255), > stone-cut VARCHAR(255), > stone-clarity VARCHAR(255), > stone-carat VARCHAR(255), > supplier VARCHAR(255), > metal-type VARCHAR(255), > width VARCHAR(255), > length VARCHAR(255), > setting VARCHAR(255) > )"; > > // create connection > // substitute hostname, username and password > $connection = mysql_connect("mkrisher", "mkrisher", "") or die > ("Couldn't connect to server."); > > // select database > // substitute database name > $db = mysql_select_db("richmondjewelers") or die ("Couldn't open > database."); > > // execute SQL query and get result > $sql_result = mysql_db_query($db, $sql) or die ("Couldn't execute > query!"); > > I always get the "Couldn't execute query" error, is there something > else that I should be doing, watching for permission issues or > something? > > Thanks in advance, > __ Michael Krisher > __ http://www.sectiongroup.com Immediately after the mysql_db_query line, use mysql_error() to return the mysql error message. I'll hazard a guess that it is because you haven't assigned a default value to your autoincrement field. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA "I'm as busy as a bee," Tom droned.

« previous php.general (#66974) next »