OK, the output is now populated but I get the connection error again mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
so you get the die message? look at the code where you set up the connection. Have you got "or die" in there? are you setting http://php.net/manual/en/function.error-reporting.php to all errors?
Lets see your code where you set up the connection to mysql http://php.net/manual/en/function.mysql-connect.php
ok, so through conversation I've seen the mysql library that's being used, out of date, but lets work with it for now. you therefore need to have these steps in your code global $db; $db = new MySQLConnection($myDbParams); function BeforeAdd(&$values, &$message, $inline){ global $db; // rest of the function /* don't use this line // mysql_query($query) or die(mysql_error(). '<br />'.$query); // instead use this: */ $db->query($query); } PHP:
trawl through their code and see how they do it. If you're hooking into a bigger page then they will probably handle the connection for you. Check to see how they access their database variable. It will be something like what I've written.
Now I am using this: $count = $values["Number Received"]; for($i = 1; $i < $count; $i++) { $sql = "INSERT INTO `Stock` (`Hospital`,`Manufacturer`,`Department`,`Item Type`,`Batch/Lot Number`,`Expiry Date`,`Number Received`,`Received By`,`Received On`,`Package Insert/Condition Checked`,`Use Commenced By`,`Use Commenced On`,`Notes/Comments`,`Value`) VALUES (`{$values["Hospital"]}` ,`{$values["Manufacturer"]}` ,`{$values["Department"]}` ,`{$values["Item Type"]}` ,`{$values["Batch/Lot Number"]}` ,`{$values["Expiry Date"]}` ,`{$values["Number Received"]}` ,`{$values["Received By"]}'` ,`{$values["Received On"]}` ,`{$values["Package Insert/Condition Checked"]}` ,`{$values["Use Commenced By"]}` ,`{$values["Use Commenced On"]}` ,`{$values["Notes/Comments"]}` ,`{$values["Value"]}`);"; CustomQuery($sql); } return true; Code (markup): But I get an error (thankfully not a connection error) This is driving me mad!