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