Jump to content

Recommended Posts

Hello Sir,

 

I need one help in my php file.. I have one database information in php file where form query go but when website lost database connection it shows error system is busy.. Is it Possible i add 2 database informations if one get lost query pass to another database if both lost then it show system is busy.. If you want i will show u my coding please reply..

Link to comment
https://forums.phpfreaks.com/topic/283314-php-help/
Share on other sites

Yeah you can try as many connections as you like, just test that the connection variable isn't 0... Is your site really struggling so much that you're having this issue? (or is it a gameserver or such like?)

 

No it is just an sms site, i have local database and i have 2 networks on system both has static ip.. So if  one network down it should connect from another ip thats why want to make database settings like this.. if you want to help please tell me can i send u code in pvt?

Link to comment
https://forums.phpfreaks.com/topic/283314-php-help/#findComment-1455573
Share on other sites

 

No it is just an sms site, i have local database and i have 2 networks on system both has static ip.. So if  one network down it should connect from another ip thats why want to make database settings like this.. if you want to help please tell me can i send u code in pvt?

 

 

Post it here! Should be same as the standard code anyway, just tries again if fails...!

Link to comment
https://forums.phpfreaks.com/topic/283314-php-help/#findComment-1455580
Share on other sites

   

 

Post it here! Should be same as the standard code anyway, just tries again if fails...!

<?php
$mytext = $_REQUEST['message'];
if (strlen ($mytext) > 250) die("Unable to send  your character limit is over  250");
$text_explode = explode(" ", $mytext);
$count_explode = count($text_explode);
$count_text = count($void_text);
for ($i=0; $i<$count_text; $i++)
{
for ($j=0; $j<$count_explode; $j++)
{
if ($text_explode[$j]==$void_text[$i])
$words = "$words, $text_explode[$j]";
}
}
if (!empty($words)) {
$error .= 'You have entered valgur or suspecious words'. $words.'\n';
}
if (empty($_REQUEST['phone']) or strlen($_REQUEST['phone'])<11) { 
$error .= 'Enter Valid Phone Number e.g. 000000000000.<br><br><a href="index.php">Click here to go back, re-enter phone number!</a>';
}
#if (empty($_REQUEST['name']) or strlen($_REQUEST['name'])<7) { 
#$error .= 'Please enter your name';
#}
#if (empty($_REQUEST['message']) or strlen($_REQUEST['message'])<7) { 
#$error .= 'Please enter message';
#}

@$db = mysql_connect("localhost", "username", "password");
if (!$db) { $error .= 'System Is Busy Please Wait Some Moment.';
}
if (!empty($error)) { ?>
<font color="#FF0000"><b><?php echo $error ?></b></font>
<?php
}
else {
mysql_select_db("database",$db);

#$phone = $_POST['phone'];
$phone = ltrim($_POST['phone'], 0);
$name = $_POST['name'];
$message = $_POST['message'];
$phonenum = "+92$phone";
$message = ("From $name:\n$message\n[www.domain.com]");
$DirectionID = "2";
$TypeID = "1";
$StatusID = "1";
$StatusDetailsID = "200";
$ToAddress = "1";
$ChannelID = "0";
$BillingID = date("d/m/Y  g:i a");
$FromAddress = $name;
$CharsetID = "1";
$ToAddress = $phonenum;
$Body = $message;
$Subject = $_SERVER['REMOTE_ADDR'];
error_reporting(0);
 session_start();
    if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {

$query = "INSERT INTO Messages (DirectionID, TypeID, StatusDetailsID, StatusID, ChannelID, BillingID, FromAddress, Subject, CharsetID, ToAddress, Body) VALUES 

('$DirectionID', '$TypeID', '$StatusDetailsID', '$StatusID', '$ChannelID', '$BillingID', '$FromAddress', '$Subject', '$CharsetID', '$ToAddress', '$Body')";

//echo "<b>Recipient Number: $phone<br> Sender Name: $name<br> Message: $message<br><br><br>";

echo "<b>Your SMS Sent Successfully To: 0$phone  <br><br><a href='index.php'>Go Back To Send More Text SMS Now!</a></b>";
    unset($_SESSION['security_code']);
   } else {
   echo "<b>Error: wrong security code</b><br><br>";

	 print "<a href='index.php'>Click here to go back, re-enter security code</a>";
   }
$result = mysql_query($query);
{
?>
<br>
<br>
Advertisement
<?php
}
}
error_reporting(0);
mysql_close(); 
////
?>

look there i want to make connection of second database everything will be same just host name will be changed how to make it possible?

Link to comment
https://forums.phpfreaks.com/topic/283314-php-help/#findComment-1455592
Share on other sites

@$db = mysql_connect("localhost", "username", "password");
if (!$db) { @$db = mysql_connect("remotehost", "username", "password");
                if (!$db) { ...blah blah blah... }
}

you sure if both database are connected it will send from one first? 

Link to comment
https://forums.phpfreaks.com/topic/283314-php-help/#findComment-1455616
Share on other sites

The "if(!$db)" will obviously only execute if it's false!

 

Please tell me is it fine?

@$db = mysql_connect("IP", "username", "password");
if (!$db) { @$db = mysql_connect("ip", "username", "password");
}
if (!$db) { $error .= 'System Is Busy Please Wait Some Moment.';
}
Edited by host-provider
Link to comment
https://forums.phpfreaks.com/topic/283314-php-help/#findComment-1455643
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.