kyle boyce kyle boyce - 7 months ago 45
PHP Question

PHP No database found

So it says no database selected, please help me as my hosting cant

<?php
$sitename = "http://devilgaming.phy.sx/csgopie.xyz/";
$link = @mysql_connect("localhost", "devilgam_csgopie", "ssb12boycek1");
$db_selected = mysql_select_db('devilgam_csgopie', $link);
mysql_query("SET NAMES utf8");

function fetchinfo($rowname,$tablename,$finder,$findervalue)
{
if($finder == "1")
$result = mysql_query("SELECT $rowname FROM $tablename");
else
$result = mysql_query("SELECT $rowname FROM $tablename WHERE
`$finder`='$findervalue'") or die (mysql_error());

$row = mysql_fetch_assoc($result);
return $row[$rowname];
}
?>

Answer

Where is says

$result = mysql_query("SELECT $rowname FROM $tablename WHERE
   `$finder`='$findervalue'") or die (mysql_error());
$row = mysql_fetch_assoc($result);

The mysql_fetch_assoc() function returns an array of rows that are associative arrays. To access the rows you would do:

foreach ($row as $some_row) {
    echo $some_row[$rowname];
}
Comments