I have this function below:
function mySqlConnect($sql) {
$sqlConnect = mysql_connect("host", "user", "pass");
mysql_select_db("database", $sqlConnect);
$query = mysql_query($sql);
return $query;
}
I pass the $sql into it but get this error:
Warning: Supplied argument is not a valid MySQL result resource
The line it refers to has:
while($data = mysql_fetch_row($query)) {
print "<h5>".$data[0]."</h5>";
print $data[5];
print "<br /><div class=\"smallPrint\">Added: ".$data[6]."</div>";
}
How would you go about creating a function that hold all the user/database details and all I hae to do is pass it the SQL?
I have posted this once before but am still stuck. Anyone else got any ideas? I don't want to have to repeat the same peice of code across the whole site 20 times 🙂
Tony.
Tony.