Forum Moderators: open
I am new to PHP and MySQL and have come across a problem I have no idea of solving. . . .
I've created a PHP web application in Dreamweaver, which uses a MySQL database, containing 14 tables.
On one page, I use a an SQL query to select data from 10 of the tables in the database.
However, when I try to preview the page in a browser, a PHP warning stating that the MySQL engine has run out of memory.
Is there a way of increasing the Memory Cache of the engine, or a way to optimize the performance?
I never selected data from 10 tables before in one query but that shouldn't make MySQL bottom out.
You could try either creating a "php.ini" file in your script's directory with "memory_limit=~M" where you can replace the ~ with the memory PHP should use. If the INI file doesn't work, you can just "ini_set" the memory_limit variable in PHP.
Don't think I'm using INNER JOIN (just INDEXing and FOREIGN KEYS) and I don't have my database/table script at hand either (it's at work but can forward it to you tomorrow).
In one query, I access one field (column) from 10 different tables, to populate an HTML table on a single page.
I don't know much about php.ini, or where to place it in my directory, could you explain this or give me an example?
Things might be clearer tomorrow, when I can give you my scripts.
Many thanks!
Samuel
This is my original SQL script, to create the Database:
DROP DATABASE IF EXISTS dbjobs;
CREATE DATABASE dbjobs;
USE dbjobs;
CREATE TABLE tbl_users (
userid tinyint(3) unsigned NOT NULL auto_increment,
username varchar(15) NOT NULL,
userpassword varchar(15) NOT NULL,
userlevel enum ('Administrator','Contributor') NOT NULL,
PRIMARY KEY USING BTREE (userid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO tbl_users (userid, username, userpassword, userlevel)
VALUES (1,'User A','Password A','Administrator');
CREATE TABLE tbl_customers (
custid int(10) unsigned NOT NULL auto_increment,
custname varchar(30) NOT NULL,
PRIMARY KEY USING BTREE (custid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO tbl_customers (custid,custname)
VALUES (1,'Customer A');
CREATE TABLE tbl_doctype (
doctypeid int(10) unsigned NOT NULL auto_increment,
doctypename varchar(30) NOT NULL,
PRIMARY KEY USING BTREE (doctypeid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO tbl_doctype (doctypeid, doctypename)
VALUES (1,'Doc Type A');
CREATE TABLE tbl_languages (
langid int(10) unsigned NOT NULL auto_increment,
langname varchar(3) NOT NULL,
PRIMARY KEY USING BTREE (langid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO tbl_languages (langid, langname)
VALUES (1,'EN');
CREATE TABLE tbl_translators (
transid int(10) unsigned NOT NULL auto_increment,
transname varchar(30) NOT NULL,
PRIMARY KEY USING BTREE (transid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO tbl_translators (transid, transname)
VALUES (1,'Translator A');
CREATE TABLE tbl_freelancer (
freeid int(10) unsigned NOT NULL auto_increment,
freename varchar(50) NOT NULL,
freeaddress varchar(255),
freeemail varchar(100),
freewebsite varchar(100),
freephone varchar(100),
freemobile varchar(100),
freefax varchar(100),
freepayterms enum('14','30') default '30',
freebank varchar(255),
freelink varchar(100),
PRIMARY KEY USING BTREE (freeid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE tbl_service (
servid int(10) unsigned NOT NULL auto_increment,
servfree int(10) unsigned NOT NULL,
servtitle enum('t','p','m') NOT NULL,
servlangs int(10) unsigned NOT NULL,
servlangt int(10) unsigned NOT NULL,
servcurrency varchar(10) NOT NULL,
servprate int(10) unsigned NOT NULL,
PRIMARY KEY (servid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE tbl_projects (
projid int(10) unsigned NOT NULL auto_increment,
projtitle varchar(100) NOT NULL,
projstart varchar(10) NOT NULL,
projdue varchar(10) NOT NULL,
projcust int(10) NOT NULL,
projcontact varchar(30) NOT NULL,
projanalysis varchar(255) NOT NULL,
projtype enum('t','nt') NOT NULL,
projstatus enum('o','e','h','c') NOT NULL,
projurl varchar(150),
PRIMARY KEY (projid),
CONSTRAINT projcust_fk FOREIGN KEY(projcust) REFERENCES tbl_customers(custid) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE tbl_jobs (
jobid int(10) unsigned NOT NULL auto_increment,
jobno int(10) unsigned NOT NULL,
jobtitle varchar(100) NOT NULL,
jobcust int(10) unsigned NOT NULL,
jobdue varchar(10) NOT NULL,
jobdoctype int(10) unsigned NOT NULL,
joblang int(10) unsigned NOT NULL,
jobpages int(10) unsigned,
jobwnet int(10) unsigned,
jobwgross int(10) unsigned,
jobprepared enum('n','y') NOT NULL default 'n',
jobenq enum('n','y') NOT NULL default 'n',
jobtransih enum('n','y') NOT NULL default 'n',
jobtransuser int(10) unsigned NOT NULL,
jobtransos enum('n','y') NOT NULL default 'n',
jobfreeuser int(10) unsigned NOT NULL,
jobtransshipdate varchar(10),
jobtransduedate varchar(10),
jobtranscomplete enum('n','y') NOT NULL default 'n',
jobtranscompletedate varchar(10),
jobrtype enum('n','y') NOT NULL default 'n',
jobrtypedate varchar(10),
jobnotes varchar(255),
jobftypeuser int(10) unsigned NOT NULL,
jobftype enum('n','y') NOT NULL default 'n',
jobspell enum('n','y','na') NOT NULL default 'n',
jobftypedate varchar(10),
jobproofsent enum('n','y') default 'n',
jobproofuser int(10) unsigned,
jobproofsentdate varchar(10),
jobcorrec enum('n','y','na') default 'n',
jobcorrecdate varchar(10),
jobcoruser int(10) unsigned,
jobcordoc enum('n','y''na') default 'n',
jobcordocdate varchar(10),
jobcormem enum('n','y','na') default 'n',
jobcormemdate varchar(10),
jobcleanm enum('n','y','na') default 'n',
jobcleanb enum('n','y','na') default 'n',
jobfcheckuser int(10),
jobfcheckrec enum('n','y') default 'n',
jobfcheckdate varchar(10),
jobfcoruser int(10),
jobfcorrec enum('n','y') default 'n',
jobfcordate varchar(10),
jobshipped enum('n','y') default 'n',
jobshippeddate varchar(10),
jobpdf enum('n','y') default 'n',
PRIMARY KEY USING BTREE (jobid),
KEY FK_tbl_jobs_1 USING BTREE (jobno),
CONSTRAINT FK_tbl_jobs_1 FOREIGN KEY (jobno) REFERENCES tbl_projects (projid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_2 USING BTREE (jobcust),
CONSTRAINT FK_tbl_jobs_2 FOREIGN KEY (jobcust) REFERENCES tbl_customers (custid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_3 USING BTREE (jobdoctype),
CONSTRAINT FK_tbl_jobs_3 FOREIGN KEY (jobdoctype) REFERENCES tbl_doctype (doctypeid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_4 USING BTREE (joblang),
CONSTRAINT FK_tbl_jobs_4 FOREIGN KEY (joblang) REFERENCES tbl_languages (langid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_5 USING BTREE (jobtransuser),
CONSTRAINT FK_tbl_jobs_5 FOREIGN KEY (jobtransuser) REFERENCES tbl_translators (transid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_6 USING BTREE (jobfreeuser),
CONSTRAINT FK_tbl_jobs_6 FOREIGN KEY (jobfreeuser) REFERENCES tbl_freelancer (freeid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_7 USING BTREE (jobftypeuser),
CONSTRAINT FK_tbl_jobs_7 FOREIGN KEY (jobftypeuser) REFERENCES tbl_users (userid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_8 USING BTREE (jobproofuser),
CONSTRAINT FK_tbl_jobs_8 FOREIGN KEY (jobproofuser) REFERENCES tbl_users (userid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_9 USING BTREE (jobcoruser),
CONSTRAINT FK_tbl_jobs_9 FOREIGN KEY (jobcoruser) REFERENCES tbl_users (userid) ON DELETE CASCADE ON UPDATE CASCADE,
KEY FK_tbl_jobs_10 USING BTREE (jobfcheckuser),
CONSTRAINT FK_tbl_jobs_10 FOREIGN KEY (jobfcheckuser) REFERENCES tbl_users (userid) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
This is the query that gives me the warning:
SELECT *
FROM tbl_jobs, tbl_projects, tbl_customers, tbl_doctype, tbl_freelancer, tbl_languages, tbl_languaget, tbl_user_prepare, tbl_users_finetype, tbl_users_proofreading, tbl_users_finalcheck, tbl_users, tbl_users_correction, tbl_users_roughtype, tbl_users_translation
WHERE jobid = colname AND tbl_projects.projid=tbl_jobs.FK_projid
Can you help?