Been lurking on Stackoverflow for a long time but this is my first post. I am receiving a error related to displaying an array which is supposed to be populated by a mysql query. The echo function just returns ArrayArrayArray
instead of what is supposed to be there. The mysql query is comparing a form input (the variable $data
) .
<?php
$data = $_POST["search"];
global $data;
// Create Connection
$con = mysqli_connect(xxxxx,xxxxxx,xxxxx,xxxxx);
// Check Connection
if (mysqli_errno($con))
{
echo "Failed To Connect To The Database" ;
}
//Perform Query To Compare And Return Results
$result_array = array();
$query = " SELECT url FROM data WHERE url LIKE '%$data%' " ;
$result = mysqli_query($con, $query);
// While Loop To Return All Comparable Results
while ($row = mysqli_fetch_array($result)) {
$result_array[] = $row['url'];
echo $result_array ;
}
?>
echo
will print a string, try using something like print_r()
or var_dump()
instead
Example
echo '<pre>';
print_r($result_array);
echo '</pre>';
<pre>
will allow for easier reading of the array
You can try with following code.
<?php echo '<pre>'; print_r($result_array); echo '</pre>'; ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With