I have written this extremly messy code, which is quite simple, although gives a very bizarre output from what is expected. All that is ment to happen is for some data to be inserted into the MySQL database, although this happens and all data is inserted as planned, the error message is still expressed with "No database selected", even through a database has been selected and the data inserted into it as wanted! Can someone see what I'm missing?
function ddminsertordernumber() {
global $ddmmodel,$ddmcase,$ddmprocessor,$ddmmainboard,$ddmharddisk,$ddmmemory,$ddmcdr,$ddmdvd,$ddmfloppy,$ddmgraphics,$ddmmodem,$ddmnetwork,$ddmsoundcard,$ddmspeakers,$ddmmoniter,$ddmkeyboard,$ddmsoftware,$ddmsoftbundle,$ddmdelivery,$ddmvat,$ddmtotal,$ddmexcvat;
$link = mysql_connect("localhost", "username", "pass")
or die ("Could not connect");
mysql_select_db ("website")
or die ("Could not select database");
$ddmonquery = mysql_query (("SELECT ordernumber FROM `cellorders` ORDER BY `ordernumber` DESC")) or die ("Something wrong in getting unique num <br>Error: " . mysql_error() . "<br><br>" . $query);
while ($fetchddmonquery = mysql_fetch_array($ddmonquery)) {
$ddmon = $fetchddmonquery[ordernumber]+1;
$query = ("INSERT INTO `cellorders` (`ordernumber`, `model`, `case`, `processor`, `mainboard`, `harddisk`, `memory`, `cdr`, `dvd`, `floppy`, `graphics`, `modem`, `network`, `soundcard`, `speakers`, `moniter`, `keyboard`, `software`, `softbundle`, `vat`, `excvat`) VALUES ('$ddmon','$ddmmodel','$ddmcase','$ddmprocessor','$ddmmainboard','$ddmharddisk','$ddmmemory','$ddmcdr','$ddmdvd','$ddmfloppy','$ddmgraphics','$ddmmodem','$ddmnetwork','$ddmsoundcard','$ddmspeakers','$ddmmoniter','$ddmkeyboard','$ddmsoftware','$ddmsoftbundle','$ddmvat','$ddmexcvat')");
mysql_query ($query) or die ("Something wrong in ddminsertordernumber <br>Error: " . mysql_error() . "<br><br>" . $query);
ddminsertintocatalog($ddmon,$ddmexcvat,"CellSeries");
}
mysql_close();
ddminsertintocatalog($ddmon,$ddmexcvat,"CellSeries");
}
PLEASE HELP!