I have a function called ObtainUserName in a page called functions.php. For an instance im working on my page purchase_edit.php. Inside that page i have the following data Name, Date, Means of Payment, Total, Books and all of them are in php. This is what im talking about. If i remove the ObtainUserName, it displays the iduser with no problem. if i put ObtainUserName its display a funny background color that displays <>Name</p> only…
function ObtainProductName($identifier)
{
global $database_databaseConnection, $databaseConnection;
mysql_select_db($database_databaseConnection, $databaseConnection);
$query_QueryFunction = sprintf("SELECT name FROM book WHERE idbook = %s",$identifier);
$QueryFunction = mysql_query($query_QueryFunction, $databaseConnection) or die(mysql_error());
$row_QueryFunction = mysql_fetch_assoc($QueryFunction);
$totalRows_QueryFunction = mysql_num_rows($QueryFunction);
return $row_QueryFunction['name'];
mysql_free_result($QueryFunction);
}
function ObtainProductName($identifier)
{
global $database_databaseConnection, $databaseConnection;
mysql_select_db($database_databaseConnection, $databaseConnection);
$query_QueryFunction = sprintf("SELECT name FROM book WHERE idbook = %s",$identifier);
$QueryFunction = mysql_query($query_QueryFunction, $databaseConnection) or die(mysql_error());
$row_QueryFunction = mysql_fetch_assoc($QueryFunction);
$totalRows_QueryFunction = mysql_num_rows($QueryFunction);
$result = $row_QueryFunction['name'];
// DEBUG - unrem following line to see $result
// var_dump( $result );die;
return $result;
# return $row_QueryFunction['name'];
# mysql_free_result($QueryFunction);
}
I think the return is not necessary and also clears/removes $row_QueryFunction[‘name’];
The function ObtainUserName comes first… Then Function ObatinProductName… Do you want it like this…
function ObtainUserName($whatever=NULL)
{
echo METHOD;
die;
}
function ObtainProductName($whatever=NULL)
{
global $database_databaseConnection, $databaseConnection;
mysql_select_db($database_databaseConnection, $databaseConnection);
$query_QueryFunction = sprintf(“SELECT name FROM book WHERE idbook = %s”,$identifier);
$QueryFunction = mysql_query($query_QueryFunction, $databaseConnection) or die(mysql_error());
$row_QueryFunction = mysql_fetch_assoc($QueryFunction);
$totalRows_QueryFunction = mysql_num_rows($QueryFunction);
I do not think the function order is a problem, so give it a try.
Off topic
Please note that preceding text with the < highlights PHP scripts but removes underscores. to prevent this from happening insert three backticks on a new line, then your script followed by a new line and three more backticks.