Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi everyone, I got a problem while using mysql_query inside a function I have made. Simply I connect to mysql outside the function, I select the db (inside the function) and finally I use the mysql_query function but it fails without any reason. If I write all the entire code outside my function, it works!
The main code (an example):Code: Select all
<?php
require_once('path of the php files that manage the connection');
function deleteReport($userid)
{
mysql_select_db($database_dblinker, $dblinker);
$query_report = "SELECT * FROM report WHERE userid = $userid";
$rs_report = mysql_query($query_report, $dblinker) or die(mysql_error());
$reportArray = mysql_fetch_assoc($rs_report);
mysql_free_result($rs_report);
return $reportArray;
}
?>Code: Select all
<?php
$result = deleteReport(50);
?>After echoing a sentence after every istructions, I found that the problem was the mysql_query function, but I can't understand why it doesn't work inside my function, but it's ok outside.
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]