Feb 8, 2018 05:49 PM
(This post was last modified: Feb 8, 2018 05:49 PM by SharoKurdi.)
hi 😅
i want use Break in mysqli Connect But I cant I get This Error
Code PHP Parse error: syntax error, unexpected 'break' (T_BREAK)
THis mysql Connect Code
PHP Code
<?php $conn=@mysqli_connect('localhost','root','1234') or break;
i dont want use DIE i want Break it But i cant
THnx
Feb 8, 2018 06:14 PM
(This post was last modified: Feb 8, 2018 06:24 PM by RumbleFrog.)
Why would you use break if you don't know what it's designed for? A break is meant to be used within a loop, termination inside of a loop.
(Feb 8, 2018 06:14 PM)RumbleFrog Wrote: Why would you use break if you don't know what it's designed for? A break is meant to be used within a loop, termination inside of a loop.
i make loop for 5 server if server 1 is offline break to server 2
:/
(Feb 8, 2018 06:32 PM)SharoKurdi Wrote: i make loop for 5 server if server 1 is offline break to server 2
:/
Mind breaking the full loop code then? And it's not break, it's continue.
(Feb 8, 2018 07:37 PM)RumbleFrog Wrote: Mind breaking the full loop code then? And it's not break, it's continue.
yas But both not work
Don’t do it like that. Do if/If else statements.
(Feb 9, 2018 06:56 PM)SharoKurdi Wrote: yas But both not work
Mind providing the loop code, holy shit.
Do this man:
PHP Code
<?php $servers = array( array("Host" => 'localhost',"User" => 'root', "Pass" => '1234'), array("Host" => 'localhost2',"User" => 'root3', "Pass" => '1234'), array("Host" => 'localhost3',"User" => 'root3', "Pass" => '1234') );
$connection = null; foreach($servers as $server) { $check = @mysqli_connect($server["Host"],$server["User"],$server["Pass"]); if($check) { $connection = $check; break; } } if($connection == null) { die("Unable to find a database server that is alive"); } //Your code
(Feb 10, 2018 11:04 AM)Charger Wrote: Do this man:
PHP Code
<?php $servers = array( array("Host" => 'localhost',"User" => 'root', "Pass" => '1234'), array("Host" => 'localhost2',"User" => 'root3', "Pass" => '1234'), array("Host" => 'localhost3',"User" => 'root3', "Pass" => '1234') );
$connection = null; foreach($servers as $server) { $check = @mysqli_connect($server["Host"],$server["User"],$server["Pass"]); if($check) { $connection = $check; break; } } if($connection == null) { die("Unable to find a database server that is alive"); } //Your code
thnx for reply problem Connect Freez in connection code if server not Found
PHP Code
<?php $check = @mysqli_connect($server["Host"],$server["User"],$server["Pass"]);
i change to Pdo its faster and bypass errors and freez
thnx For Help
(Feb 12, 2018 09:07 AM)SharoKurdi Wrote: thnx for reply problem Connect Freez in connection code if server not Found
PHP Code
<?php $check = @mysqli_connect($server["Host"],$server["User"],$server["Pass"]);
i change to Pdo its faster and bypass errors and freez
thnx For Help
PDO is much better than mysqli_. Glad this solution worked for you.
Feel free to post a new thread if you have any further issues/questions.
(Feb 12, 2018 01:31 PM)Charger Wrote: PDO is much better than mysqli_. Glad this solution worked for you.
Feel free to post a new thread if you have any further issues/questions. PHP Code
<?php $conn=@mysqli_connect('localhost','root','1234') or die('cannot connect');
Writeln('Give me a Target >');
|