Bob Myles Bob Myles - 1 year ago 80
MySQL Question

php mysql database select

I'm to retrieve some variables from database say a mobile number that is to be the recipient of a sms. When I try passing it as a service argument I get stdClass Object ( ) ...How do I pass it? Kindly, any one?

sample code:

$sql = "SELECT msisdn FROM customer WHERE id = 5";

$result1 = mysqli_query($conn, $sql);
$resultarr = mysqli_fetch_assoc($result1);

$mobilenumber = $resultarr;
$message = $_POST['Message'];

$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message

$client = new SoapClient("");

$result = $client->process($serviceArguments);

return $result;

Answer Source

mysqli_fetch_assoc .Fetch a result row as an associative array

To get mobile number form $resultarr you need to to

$resultarr = mysqli_fetch_assoc($result1);// fetch data
$mobilenumber=$resultarr['msisdn'];// get mobile number from array
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download