fixing some database issues
This commit is contained in:
parent
6ee911aee4
commit
36218b9594
3 changed files with 28 additions and 22 deletions
|
|
@ -2,24 +2,30 @@
|
|||
|
||||
$MysqlErrorsArePresent = 0;
|
||||
$GlobalMysqlHandler=mysqli_connect($GlobalMysqlHost,$GlobalMysqlUser,$GlobalMysqlPwd);
|
||||
|
||||
|
||||
if (!$GlobalMysqlHandler)
|
||||
{
|
||||
ErrorLog("[mysql.php] Can not connect to mysql database \"$GlobalMysqlHost\" as \"$GlobalMysqlUser\"!");
|
||||
$err_msg = "Cannot connect to mysql database \"$GlobalMysqlHost\" as \"$GlobalMysqlUser\"!";
|
||||
$err_msg += "\nErrno: " . mysqli_connect_errno();
|
||||
$err_msg += "\nError: " . mysqli_connect_error();
|
||||
ErrorLog($err_msg);
|
||||
$MysqlErrorsArePresent = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mysqli_select_db($GlobalMysqlHandler, $GlobalMysqlDatabase))
|
||||
{
|
||||
ErrorLog("[mysql.php] Can not select mysql database \"$GlobalMysqlDatabase\"!");
|
||||
$err_msg = "Cannot select mysql database \"$GlobalMysqlDatabase\"!";
|
||||
$err_msg += "\nErrno: " . mysqli_connect_errno();
|
||||
$err_msg += "\nError: " . mysqli_connect_error();
|
||||
ErrorLog($err_msg);
|
||||
$MysqlErrorsArePresent = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ($MysqlErrorsArePresent)
|
||||
MessageError(LangSpellHtml('SentenceDatabaseError'));
|
||||
|
||||
|
||||
function MysqlCloseDb ()
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$StartTime=time()+microtime();
|
||||
$StartTime = microtime(true);
|
||||
|
||||
//set ToDo var
|
||||
if (isset($_GET['ToDo']))
|
||||
|
|
@ -97,14 +97,14 @@ MysqlCloseDb();
|
|||
|
||||
if ($GlobalDebungMode)
|
||||
{
|
||||
$StopTime=time()+microtime();
|
||||
$StopTime = microtime(true);
|
||||
$TimeSpan=ceil(($StopTime-$StartTime)*1000);
|
||||
if ($TimeSpan<0)
|
||||
{
|
||||
ErrorLog("Execution time negative, start: '$StartTime' stop: '$StopTime' timespan: '$TimeSpan'!");
|
||||
echo "Start time: <strong>$StartTime s</strong><br>\n";
|
||||
echo "Stop time: <strong>$StopTime s</strong><br>\n";
|
||||
}
|
||||
}
|
||||
echo "Script execution time: <strong>$TimeSpan ms</strong><br>\n";
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ if (UserHasRight('EditVendors'))
|
|||
$Homepage = (isset($_POST['Homepage']))? $_POST['Homepage']:"";
|
||||
$MinBill = (isset($_POST['MinBill']))? OtherConvertToFloat($_POST['MinBill']):0;
|
||||
$ShippingCost = (isset($_POST['ShippingCost']))? OtherConvertToFloat($_POST['ShippingCost']):0;
|
||||
|
||||
|
||||
if (LockIsActive('Vendors',$_POST['Id']))
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceLockIsActive'));
|
||||
|
|
@ -66,7 +66,7 @@ if (UserHasRight('EditVendors'))
|
|||
{
|
||||
MessageError(LangSpellHtml('SentenceLockIsActive'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//////////////
|
||||
|
|
@ -77,7 +77,7 @@ if (UserHasRight('EditVendors'))
|
|||
$Homepage = (isset($_POST['Homepage']))? $_POST['Homepage']:"";
|
||||
$MinBill = (isset($_POST['MinBill']))? OtherConvertToFloat($_POST['MinBill']):0;
|
||||
$ShippingCost = (isset($_POST['ShippingCost']))? OtherConvertToFloat($_POST['ShippingCost']):0;
|
||||
|
||||
|
||||
if (!$Name)
|
||||
{
|
||||
$Error=1;
|
||||
|
|
@ -85,19 +85,19 @@ if (UserHasRight('EditVendors'))
|
|||
}
|
||||
else
|
||||
{
|
||||
$InsertVendorQuery = "INSERT INTO `Vendors` ( `Name` , `Homepage` , `MinBill` , `ShippingCost` ) VALUES ( '$Name', '$Homepage', '$MinBill', '$ShippingCost' );";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $InsertVendorQuery))
|
||||
{
|
||||
ErrorLog("[edit_vendors.php] Database error while insert new vendor!");
|
||||
$InsertVendorQuery = "INSERT INTO `Vendors` (`Name`, `Homepage`, `MinBill`, `ShippingCost`, `LockId`, `LockTime`) VALUES ('$Name', '$Homepage', '$MinBill', '$ShippingCost', 0, 0);";
|
||||
if (mysqli_query($GlobalMysqlHandler, $InsertVendorQuery) === false) {
|
||||
$err_msg = "Database error while insert new vendor!";
|
||||
$err_msg += "\nErrno: " . mysqli_connect_errno();
|
||||
$err_msg += "\nError: " . mysqli_connect_error();
|
||||
ErrorLog($err_msg);
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
MessageSuccess(LangSpell('EditVendorsSentenceVendorNewAdded'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////
|
||||
//cancel editing
|
||||
if ($ToDo=="CancelEditVendor")
|
||||
|
|
@ -116,11 +116,11 @@ if (UserHasRight('EditVendors'))
|
|||
}
|
||||
|
||||
if(UserHasRight('EditVendors') || UserHasRight('ViewSTPV'))
|
||||
{
|
||||
{
|
||||
//////////////////
|
||||
//global content
|
||||
$GlobalContent.='<table>'."\n";
|
||||
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsId').'</th>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsName').'</th>'."\n";
|
||||
|
|
@ -130,7 +130,7 @@ if(UserHasRight('EditVendors') || UserHasRight('ViewSTPV'))
|
|||
if (UserHasRight('EditVendors'))
|
||||
$GlobalContent.=' <th colspan="2">'.LangSpellHtml('EditVendorsEdit').'</th>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
|
||||
|
||||
$VendorQuery = "SELECT * FROM `Vendors`";
|
||||
$VendorQuery = mysqli_query($GlobalMysqlHandler, $VendorQuery);
|
||||
while ($Vendor=mysqli_fetch_array($VendorQuery))
|
||||
|
|
@ -189,7 +189,7 @@ if(UserHasRight('EditVendors') || UserHasRight('ViewSTPV'))
|
|||
$GlobalContent.=' </tr>'."\n";
|
||||
$GlobalContent.=' </form>'."\n";
|
||||
}
|
||||
|
||||
|
||||
$GlobalContent.='</table>'."\n";
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue