blueman378 Posted December 25, 2007 Share Posted December 25, 2007 hi guys, i have this code, <?php function $row[cName](){ global $database; $q = "SELECT * FROM " . Games . " WHERE category='$row[cName]' ORDER BY `gName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if( $num_rows == 0 ){ return '<font size="2">Games not found!</font>'; } /* Display table contents */ $content = "$num_rows"; } return $content; // You can echo $row[cName](); ?> btw $row[cName] is defined in a prior sql statment, anyway my question is is it possible to have the function name as the array results a thing it might be useful to know this code is included in this: $q = "SELECT cName FROM " . gsubcat . " ORDER BY `cName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if( $num_rows == 0 ){ return 'Cats not found!'; } ?><table border="1" cellpadding="3" cellspacing="0" ><tr><td><b>Name</b></td><td><b>Games Assigned</b></td><td><b>Actions</b></td> </tr><?php while( $row = mysql_fetch_assoc($result) ) { echo '<tr><td>'; echo $row[cName] ?></td> <td><?php include("gamecount.php"); ?> </td> <?php echo ' <td><a href="catprocess.php$action=Delete&$cat=' . $row['cName'] . '"> <img src="../images/Delete.png" alt="Delete" Title="Delete"></a><a href="catprocess.php$action=Browse&$cat=' . $row['cName'] . '"> <img src="../images/Browse.png" alt="Browse" Title="Browse"></a></td></tr>'; } ?></table> <br> <br> <?php //cat form end ?> the error i get is Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in C:\wamp\www\admin\gamecount.php on line 2 which i gather its saying it was expecting a solid value rather than a variable thanks Quote Link to comment https://forums.phpfreaks.com/topic/83105-solved-function-name-as-array-value/ 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.