I'm trying to call a mysql function inside a php function and it is not working. How do I pass a database connection to a function? See the code below that illustrates my problem.
Thanks,
Ken
//PARENT FILE
<?
include '/functions/myfunction.php;
$conn=mysql_connect($db_name, $db_user, $db_password);
mysql_select_db($dbname);
.
.
.
$result=function_call($data1, $data2);
mysql_close($conn);
?>
//END PARENT FILE
//START FUNCTION FILE
function function_call($data1, $data2){
$query=mysql_query("SELECT field FROM table WHERE data='$data1');
$row=mysql_fetch_array($query);
$field=$row['field']; // Field returns empty...
}
//END FUNCTION FILE







Bookmarks