This is my code. Where I'm wrong?
<?php
$connection = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
mysql_select_db($DB_NAME);
$img = mysql_query("SELECT * FROM wp_bwg_image");
while($res = mysql_fetch_array($img)){
echo $res;
}
?>
From this table I want to take any pictures.
This is my code. Where I'm wrong?
<?php
$connection = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
mysql_select_db($DB_NAME);
$img = mysql_query("SELECT * FROM wp_bwg_image");
while($res = mysql_fetch_array($img)){
echo $res;
}
?>
From this table I want to take any pictures.
Share Improve this question edited Mar 11, 2016 at 6:49 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Mar 10, 2016 at 16:54 Marin TsolovMarin Tsolov 112 bronze badges 3 |2 Answers
Reset to default 1Use the global $wpdb for example $myrows = $wpdb->get_results( “insert sql here");
Try this:
<?php
$connection = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
mysql_select_db($DB_NAME);
$img = mysql_query("SELECT * FROM wp_bwg_image");
while($res = mysql_fetch_array($img)){
$Image = $res['image_url'];
echo $Image;
}
?>
You are not declaring the row name from which you want to get data.
$res
is probably an object or array, tryprint_r($res);
orvar_dump($res);
to see what if anything you are ending up with. – majick Commented Mar 10, 2016 at 17:09mysql_
extensions has been depreciated in PHP 5.5 and is now removed in PHP 7. See this – Pieter Goosen Commented Mar 10, 2016 at 17:15