1
I have a PHP SOAP type Webservice on Azure and I am using Mysql in App. The bank is logging in and running...but I can’t run a simple Query! Where is the error?
<?php
$connectstr_dbhost = '';
$connectstr_dbname = '';
$connectstr_dbusername = '';
$connectstr_dbpassword = '';
foreach ($_SERVER as $key => $value) {
if (strpos($key, "MYSQLCONNSTR_localdb") !== 0) {
continue;
}
$connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
$connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
$connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
$connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
}
$link = mysqli_connect($connectstr_dbhost, $connectstr_dbusername, $connectstr_dbpassword,$connectstr_dbname);
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "<br> Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "<br> Host information: " . mysqli_get_host_info($link) . PHP_EOL;
echo "<br> host information: " .$connectstr_dbhost;
echo "<br> dname information: " .$connectstr_dbname;
echo "<br> user information: " .$connectstr_dbusername;
echo "<br> pass information: " .$connectstr_dbpassword;
echo "<br>";
//query para selecionar todos os produtos
$sql = "select * from produtos";
$result= mysqli_query($sql,$link);
var_dump($result);
$produtos = array();
$linha = mysql_fetch_assoc($result);
$total = mysql_num_rows($result);
$i =0;
if($total > 0) {
do {
echo "<br>".$linha['codigo']." ".$linha['nome']."<br>";
$produtos[$i] = $linha;
$i++;
}while($linha = mysql_fetch_assoc($result));
}
return $produtos;
mysqli_close($link);
?>
Have any dice in the bank?
– Jéf Bueno
Have...I will post the photo with the contents of the bank
– alexjosesilva
In the browser print it says that you have connected in the my_db database, and in the phpmyadmin print you are in the localdb database. Check this out.
– Thiago Lunardi