telsiin Posted November 24, 2009 Share Posted November 24, 2009 I am trying to pass a variable to a function, I believe my syntax is wrong thank you for your help Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /../../../actiontest.php on line 7 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /../../../actiontest.php on line 9 5 6 function optionAction($actiontype){ 7 mysql_select_db($database_actionrpg, $actionrpg); 8 $query_action = "SELECT * FROM actionlist WHERE actionlist.action_type = '$actiontype'"; 9 $action = mysql_query($query_action, $actionrpg) or die(mysql_error()); 10 $row_action = mysql_fetch_assoc($action); 11 $totalRows_action = mysql_num_rows($action); 12 } 13 optionAction("Attack"); 14 15 ?> Quote Link to comment https://forums.phpfreaks.com/topic/182739-function-error/ Share on other sites More sharing options...
Alex Posted November 24, 2009 Share Posted November 24, 2009 You have a scope problem. $database_actionrpg is not defined within the scope of that function. Quote Link to comment https://forums.phpfreaks.com/topic/182739-function-error/#findComment-964506 Share on other sites More sharing options...
flyhoney Posted November 24, 2009 Share Posted November 24, 2009 <?php function optionAction($actiontype) { global $database_actionrpg, $actionrpg; mysql_select_db($database_actionrpg, $actionrpg); $query_action = "SELECT * FROM actionlist WHERE actionlist.action_type = '$actiontype'"; $action = mysql_query($query_action, $actionrpg) or die(mysql_error()); $row_action = mysql_fetch_assoc($action); $totalRows_action = mysql_num_rows($action); } optionAction("Attack"); Quote Link to comment https://forums.phpfreaks.com/topic/182739-function-error/#findComment-964781 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.