Jump to content

]{ronic

Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

]{ronic's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey, I have am creating a web app to hold customer and job details.. I have the following table structures to hold the data: CREATE TABLE Customers ( customerID int(5) NOT NULL auto_increment, customer varchar(25) default NULL, contact varchar(25) default NULL, phone varchar(25) default NULL, email varchar(25) default NULL, address varchar(25) default NULL, PRIMARY KEY (customerid) ) ENGINE = INNODB; CREATE TABLE Jobs ( jobID int(5) NOT NULL auto_increment, customerID int(5) NOT NULL default '0', invoiceNumber varchar(25) default NULL, purchasOrder varchar(25) default NULL, orderDate datetime NOT NULL default '0000-00-00', dateRequired datetime NOT NULL default '0000-00-00', jobStatus varchar(25) default NULL, PRIMARY KEY (jobID) ) ENGINE = INNODB; CREATE TABLE vinyl ( vinylID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', colour varchar(25) default NULL, font varchar(25) default NULL, size varchar(25) default NULL, fileLocation varchar(25) default NULL, PRIMARY KEY (vinylID) ) ENGINE = INNODB; CREATE TABLE screenprint ( screenprintID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', colour varchar(25) default NULL, font varchar(25) default NULL, size varchar(25) default NULL, fileLocation varchar(25) default NULL, PRIMARY KEY (screenprintID) ) ENGINE = INNODB; CREATE TABLE items ( itemID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', supplier varchar(25) default NULL, code varchar(25) default NULL, colour varchar(25) default NULL, style varchar(25) default NULL, total varchar(25) default NULL, dateOrdered varchar(25) default NULL, PRIMARY KEY (itemID) ) ENGINE = INNODB; CREATE TABLE itemsqty ( itemqtyID int(5) NOT NULL auto_increment, itemID int(5) NOT NULL default '0', jobID int(5) NOT NULL default '0', size varchar(25) default NULL, quanity int(5) NOT NULL default '0', PRIMARY KEY (itemqtyID) ) ENGINE = INNODB; CREATE TABLE embroidery ( embroideryID int(5) NOT NULL auto_increment, jobID int(5) NOT NULL default '0', code varchar(25) default NULL, stitchCount varchar(25) default NULL, quanity int(5) NOT NULL default '0', PRIMARY KEY (embroideryID) ) ENGINE = INNODB; Are these tables set out correctly for the collection of data needed. Also.. am I best to use Foreign Keys? My understanding of using foreign keys is not in place for queries as such, more to keep the tables clean of miss matched records etc? Thanks
  2. Erm Hate that, lost so much time lol.. Thanks
  3. This works: $dbhost = 'localhost'; $dbuser = 'root'; $dbpasswd = ''; $database = 'test'; $connection = mysql_connect("$dbhost","$dbuser","$dbpasswd") or die ("Couldn't connect to server."); $db = mysql_select_db("$database", $connection) or die("Couldn't select database."); $sql = mysql_query("SELECT firstname FROM clients ORDER BY firstname ASC"); while ($row = mysql_fetch_array($sql)) { echo ''.$row['firstname'].'<br />'; } This fails: require_once 'includes/db.php'; $sql = mysql_query("SELECT firstname FROM clients ORDER BY firstname ASC"); while ($row = mysql_fetch_array($sql)) { echo ''.$row['firstname'].'<br />'; } with error: I can use require once on other files from the includes folder ok.. Seems to be only the db.php file that plays up. dp.php: <? $dbhost = 'localhost'; $dbuser = 'root'; $dbpasswd = ''; $database = 'test'; $connection = mysql_connect("$dbhost","$dbuser","$dbpasswd") or die ("Couldn't connect to server."); $db = mysql_select_db("$database", $connection) or die("Couldn't select database."); ?> Strange issue, It only fails using xampp locally.. the basic script works fine on other professional servers as it should
  4. Hi, If I place the following into a file called db.php and save it into folder called includes using xampp: $dbhost = 'localhost';$dbuser = 'root';$dbpasswd = '';$database = 'test'; $connection = mysql_connect("$dbhost","$dbuser","$dbpasswd") or die ("Couldn't connect to server."); $db = mysql_select_db("$database", $connection)or die("Couldn't select database."); and try to access it by adding require_once 'includes/db.php'; into index.php, I get the following error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index.php on line 28 But if I paste the code directly into index.php it works fine.. Both ways work fine using my paid hosting.. Whats going wrong? Thanks
×
×
  • 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.