PHP - Php Dice Roll Function Help
I am not a very good PHP programmer, and I got a project to "work" on.
I need help writing a Dice Roll Function. This is how I'm supposed to do the two functions: New Function: dice_roll (int sides) - $ returns a random number of how many sided the dice is, between 1 and the $. New Function: dice_roll_str (string dicestr) - A string describing the dice [0-9] + d [0-9 ]+[+-][ 0-9] + size (d <number_of_dices> <number_of_sides> [+-][modifying_value]) - For example if I call the function with "3d6-3", this means: we throw 3 times with a 6-sided dice, add it up, then subtract 3-t. - The function is to return a false value on error - Possible errors: - Minimum number of of sides of the dice is 2 the maximum is 24 - A minimum number of dices 1 the maximum is 8 - The result should always be a positive number, which is not greater than twice of the result we got. I've already done the first function. This is my code: Code: [Select] function dice_roll($sides_num) { $rand_num = rand(1, $sides_num); return $rand_num; } I'm not sure it correct. It is the second function that I don't know how to do. Please, if you can help I'd be really grateful. If you can please put explanations on how the code works. Thank you so much, Evermore Similar TutorialsSo i am a noob with php, I am looking to design a ten sided dice roller that shows the results to everyone along with who rolled it. Hey guys. I'm new around here, and I come to you to get some help on a coding. I have made a program that selects two variable via the POST function and generates a set amount of random numbers between 1 and $B. That thing works like a charm and it places them all neatly in a table, but now I want to get on with the program and make it count the amount of all the numbers specified in variable $C. EXAMPLE: Generated 9 random numbers with a value between 1 and 10, echoing out the following: 9 8 2 6 4 7 3 10 5 Now I want it to count the numbers 8 and 9, telling me how many there are. If I can get this to work, I then want it to count the amount of 10's, add them to the amount of 8's and 9's, plus reroll them, add the following 8's and 9's, then repeat the process of counting and rerolling the 10's, then adding the 8's and 9's. Any of you have an idea of how to make this work? I need some help with a dice rolling project. Here is what code I've got so far I just need some help with the for and while loops. I have to simulate the the dice being rolled (between 1-6) 5000 times and track the results in a table. If anyone could help me, I'd be VERY APPRECIATIVE. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>"Statistical analysis of rolling a six-sided die"</title> </head> <body> <h2>Statistical analysis of rolling a six-sided die</h2> <br/> <table width='600' border='1' cellspacing='0' cellpadding='5' align='center'> <?php $side1 = 1; $side2 = 2; $side3 = 3; $side4 = 4; $side5 = 5; $side6 = 6; for ($i =1; $i <= 5000; i++) { $roll = mt_rand(1, 6); } ?> </table> </body> </html> Im new to php and i cant get my program to display correctly. I want it to take a user's guess of a single Die roll and display whether the user guessed correctly and display a picture of the corresponding Die. i think there is something wrong with my "If" statement or logic. Please Help. Here's the Code: INPUT FORM: <html> <body> <form name = "Dice Game" action="diceroll.php" method="post"> Your Guess: <br> <input type= "text" name="" size= "1"> <input type ="submit" name = "submit"> </form> </body> </html> OUTPUT FORM: <html> <body> <?php $roll = $_POST['submit']; $dice = rand(1, 6); if ($roll == 1 && $dice == 1){ print "Great Job, You're Good!"; }else if ($roll == 1 && $dice /= 1) { print "Wrong"; } else if ($roll == 2 && $dice == 2) { print "Great Job, You're Good!";} else if ($roll == 2 && $dice /= 2) { print "Wrong"; } else if ($roll == 3 && $dice == 3) { print "Great Job, You're Good!"; } else if ($roll == 3 && $dice /= 3) { print "Wrong"; } else if ($roll == 4 && $dice == 4) { print "Great Job, You're Good!"; } else if ($roll == 4 && $dice /= 4) { print "Wrong"; } else if ($roll == 5 && $dice == 5) { print "Great Job, You're Good!"; } else if ($roll == 5 && $dice /= 5) { print "Wrong"; } else if ($roll == 6 && $dice == 6) { print "Great Job, You're Good!"; } else if ($roll == 6 && $dice /= 6) { print "Wrong"; } else { print " "; } if($dice == 1) print "<img src='dice1.png'>"."<br>"; if($dice == 2) print "<img src='dice2.png'>"."<br>"; if($dice == 3) print "<img src='dice3.png'>"."<br>"; if($dice == 4) print "<img src='dice4.png'>"."<br>"; if($dice == 5) print "<img src='dice5.png'>"."<br>"; if($dice == 6) print "<img src='dice6.png'>"."<br>"; else { print "Thanks for playing". "<br>"; } ?> <form name= "back" action= "dice.php" method= "post"> <input type="submit" name="back" value ="Play Again"> </form> </body> </html> Hello, I have a simple dice system script I am using in a chat program for a website and I was wondering if someone could simply tell me how to limit the number of dice being rolled. Here are the two chunks of script that make it work: if($irc_cmd == '/d') { if($irc_cmd == $txt) { // this can only happen with a no dice - '/d' - a help request // return an explanation of the correct format $text = "dice command is /d [[n]D]s[Xm|+a|-d|/q]*"; $this->sendToUser(null, new Message($type, $this->userid, null, $text, $this->color)); return 'ok'; } // create standard failure message $invalid_msg = new Message($type, $this->userid, null, 'ERROR: invalid dice command - '.$txt.' - enter /d for help', $this->color); // remove the original command from the dice string $dicestring = str_replace($irc_cmd,'', $txt); // use lowercase versions of D and X to make parsing simpler $dicestring = strtolower($dicestring); // remove any user entered spaces $dicestring = str_replace(' ', '', $dicestring); // note that all modifiers will follow the dice spec 'nDs' // number of dice is optional e.g. 1d4 d4 and 4 all represent a single 4-sided die // if the first token is blank, then the user intended for one die e.g. /d d20 means /d 1d20 // if the is no 'd' then the user intended one die e.g. /d 20 means /d 1d20 $parts = explode('d', $dicestring); if(count($parts)>2) { // only one 'd' is allowed $this->sendToUser(null, $invalid_msg); return 'ok'; } elseif(count($parts)==1) { // if no 'D' assume '1' die $number = 1; } else { $number = (int)$parts[0]; if ($parts[0] == "") { // if $number == 0 // if no number assume '1' die $number=1; } elseif ("$number" != "$parts[0]") { // only integers allowed $this->sendToUser(null, $invalid_msg); return 'ok'; } $dicestring = $parts[1]; } if($number < 1) { // can't allow a negative number of dice $this->sendToUser(null, $invalid_msg); return 'ok'; } // check for sides and modifiers // expand the string to put spaces around all the tokens we want $dicestring = str_replace('+', ' + ', $dicestring); $dicestring = str_replace('-', ' - ', $dicestring); $dicestring = str_replace('x', ' x ', $dicestring); $dicestring = str_replace('/', ' / ', $dicestring); // explode the whole thing to create tokens $parts = explode(' ', $dicestring); // the only other tokens should be integers // allowed formats from here are s[Xm][+a][-d][/q] // we should allow any series of these in any order, applying them left to right // the first part must be the sides $sides = (int)$parts[0]; if ("$sides" != "$parts[0]") { $this->sendToUser(null, $invalid_msg); return 'ok'; } if($sides < 1) { // can't allow a negative number of sides $this->sendToUser(null, $invalid_msg); return 'ok'; } // get the user's name //$user = ChatServer::getUser($this->userid); //$name= $user['login']; // start writing the reply string $text = '*rolls* '.$number.'d'.$sides.': '; // seed the randomizer srand(time()); // with number and sides, roll the dice, adding them up $total = 0; for($i = 0; $i < $number; $i++) { $roll = (rand()%$sides)+1; if($i != 0) $text .= '+'; $text .= $roll; $total += $roll; } // now apply all the modifiers to the roll, in the order the user specified them for ($i = 1; $i < count($parts); $i+=2) { // the value needs to be an integer $value = (int)$parts[$i+1]; $v = $parts[$i+1]; if ("$value" != "$v") { $this->sendToUser(null, $invalid_msg); return 'ok'; } // the token needs to be one of the operators - otherwise abort $token = $parts[$i]; switch ($token) { case '+': // add $total += $value; break; case '-': // subtract $total -= $value; // make minimum 1 - remove this like to allow 0 and lower if ($total<1) $total=1; break; case 'x': // multiply $total *= $value; break; case '/': // divide - round up so 1d6/3 will be the same as 1d2 $total = ceil($total/$value); break; default: $this->sendToUser(null, $invalid_msg); return 'ok'; } // add the modifier to the display string $text .= $token.$value; } // and display the final result $text .= ': '.$total; // gets sent to particular room, but with users name tacked on, so a user could spoof it // at least 'msgu' looks different $this->sendToRoom(null, new Message('rpg', $this->userid, $this->roomid, $text)); return 'ok'; } and function Message($command, $userid = null, $roomid = null, $txt = null, $color = null) { $this->command = $command; if ($command == 'rpg') $this->command = 'msgu'; $this->userid = $userid; $this->roomid = $roomid; $this->color = htmlColor($color); if($command != 'rpg') { $txt = str_replace('*rolls*', 'rolls', $txt); } if(isset($txt)) { $this->txt = $this->parse($txt); } } So again all I want it to do is limit the number of dice being rolled because right now someone can do a /d 1000000d100000 and completely crash the chat for everyone. I am thinking 100 on either variable would be plenty. Thanks for your help! For user content validation, I built my own custom class which is injected with an array which specified how the data will be validated and how to respond to the user if invalid data. It has a method to validate server side as well as a method to produce the jQuery validation plugin's client configuration JSON. The configuration array is defined by one or more JSON file located on the server. I am trying to determine where I should define which files should be used to validate data for a given entity. The easiest location is to store them directly in the entity in question, however, I have heard people voice that the entity shouldn't be responsible for validation. It isn't directly responsible how I am doing this, but would like to know whether there are any specific reasons why doing so might have undesirable consequences. Alternately, I can have them defined in the repository, however, it requires more logic. public function update(int $idPublic, array $params): Entity { $entity=$this->read($idPublic); //Option 1 $validationFiles=$entity->getValidatorFiles(); //Option 2 $repo=$this->em->getRepository(get_class($entity)); $validationFiles=$repo->getValidatorFiles(); $rules=$this->filesToArr($files); $validator=$this->validator($rules); //Closure will create new object $validator->validateNameValue($params); //Update entity and save return $entity; }
Hello all, I have some piece of code that is nested like this $variable = 'This is a global argument'; function parentFunction($variable) { function childFunction() { echo 'Argument of the parent function is '.$GLOBALS['variable']; } childFunction(); } parentFunction(5); What I want to know is - Is there a way to access a variable from the parent function without passing arguments to the child function? (Something like how classes have parent::?). I don't want to use $GLOBALS because it might cause some variable collision, and I didn't want to pass arguments because incase I decide to change the arguments in the parent function I'd have to do it in the child function aswell. From my searching around in the Internet it seems like this is not possible, but if theres a slight chance that there might be something out there, i'm willing to give it a shot . Thanks in advance Question 1) Is the only and proper way to call a parent function "parent::function()"? Are there other/better ways from within a child function? Question 2) What are the deciding factors for when to make a function or attribute static? How do you make that decision? Assuming 5.3... Thanks. I need to call usort from a class function, and I'm puzzled about how to define the comparison function. I've tried to define the comparison function in the same class, but I can't get usort to call it. I found one hint that it will work if I make the comparison function static, but I tried that, and it didn't work for me. If I define the comparison function outside the class, it won't have access to object properties that it needs to operate. The only solution I can think of is to define the comparison function outside the class and put the object properties it needs in globals. Is there a cleaner way to do this? I have this function completely written in my class file that I am working on. The point to this function is to be able to check the login of a user or administrator for either of the control panels associated with my site. It will check the session intime as well as the page / module referenced. Once it passes all those checks, it will check and ensure the emailaddress/password stored in the current session still holds true and the account is still active... if the account is still active it will update the lastActivity as well as update all of the session variables with what is currently in the database. What I am looking for is basically a look at the function, see if it looks good.. If there is any part to it that could create security holes for the site just off the login function itself... Usage: $q->validUser($_SESSION['user'], $_mod); <?php function validUser($sess, $p) { if ($sess['inTime'] == '' && $p != 'login' && $p != 'logout') { session_destroy(); $login = '0'; $_int = ''; return $login; } else if ($sess['inTime'] < time()-3600 && $p != 'login') { $sess['inTime'] = ''; session_destroy(); $this->check_login($sess, $p); } else { $this->user = $sess['emailAddress']; $this->pass = $sess['password']; $login = $this->sql_query("SELECT * FROM users WHERE emailAddress = '".$this->user."' AND password = '".$this->pass."' AND status = '1' LIMIT '1'"); if ($login = $this->sql_numrows($login) < 1) { $sess['inTime'] == ''; session_destroy(); $login = '0'; } else { // logged in, lets update the database for last_activity AND the session. $this->sql_query("UDATE users SET lastActivity = '".now()."' WHERE emailAddress = '".$this->user."'"); $login = $this->sql_query("SELECT * FROM users WHERE emailAddress = '".$this->user."' AND password = '".$this->pass."' AND status = '1' LIMIT '1'"); $login = mysql_fetch_assoc($login); foreach ($login as $key => $value) { $sess[$key] = $value; } $sess['inTime'] = time(); $login = '1'; } return $login; } } ?> That is the main function, sql_query and sql_numrows is: <?php function sql_query($query = "", $transaction = FALSE) { unset($this->query_result); if ($query != "") { $this->num_queries++; if ($transation == BEGIN_TRANSACTION && !$this->in_transation) { $result = mysql_query("BEGIN", $this->db_connect_id); if (!$result) { return false; } $this->in_transaction = TRUE; } $this->query_result = mysql_query($query, $this->db_connect_id); } else { if ($transaction == END_TRANSACTION && $this->in_transaction ) { $result = mysql_query("COMMIT", $this->db_connect_id); } } if ($this->query_result) { unset($this->row[$this->query_result]); unset($this->rowset[$this->query_result]); if ($transaction == END_TRANSACTION && $this->in_transaction ) { $this->in_transaction = FALSE; if (!mysql_query("COMMIT", $this->db_connect_id)) { mysql_query("ROLLBACK", $this->db_connect_id); return false; } } return $this->query_result; } else { if ($this->in_transaction ) { mysql_query("ROLLBACK", $this->db_connect_id); $this->in_transaction = FALSE; } return false; } } function sql_numrows($query_id = 0) { if(!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_num_rows($query_id) : false; } ?> Any insight that can help to benefit these functions would be appreciated. When I put this chunk of code into it's own function: function fetch_all ($dbc, $query) { include ('knuffix_list_func.php'); pagination_start ($dbc, $query); $offset = $pag_array[0]; $rows_per_page = $pag_array[1]; $query = $query . " LIMIT $offset, $rows_per_page"; echo "test query: " . $query; knuffix_list ($query, $dbc); pagination_end ($pag_array); } And when I echo out the query as you can see in the example, then I notice that the variables $offset and $rows_per_page never get appended. I set the variable $pag_array to a global inside the function pagination_start(). It usually works when I DON'T wrap a function around this chunk of code, but if I do wrap a function around everything then the global suddenly won't work anymore. Btw, this also won't work if I wrap a function around the function DECLARATIONS. Any ideas, how I could make it work? I want to define a function instead of repeating query in all my php pages. I call a function by passing an $id value and from that function i have to get all the info related to that id, like name, description and uom.
I am trying to do this, but i dont know how to get these values seperately.
here is my function
function items($item_id) { $details = array(); $result = mysql_query("select item_id, name, uom, description from items where item_id=".$item_id."") or die (mysql_error()); while($row = mysql_fetch_array($result)) { $details[] = array((stripslashes($row['name'])), (stripslashes($row['uom'])), (stripslashes($row['description']))); } return $details; }and i call my function like this $info = items($id);Can somebody guide me in this Hi all, I want to call a javascript function from a php function like this: public function Buscar() { $HoraInicio = $_POST['edtHoraInicio']; $HoraFin = $_POST['edtHoraFin']; $FechaInicio = $_POST['edtFec1']; $FechaFin = $_POST['edtFec2']; $FechaMax = $FechaFin." ".$HoraFin.":00"; $FechaMin = $FechaInicio." ".$HoraInicio.":00"; $_GET["FechaMax"] = $FechaMax; $_GET["FechaMin"] = $FechaMin; echo $FechaMin; echo "<script language=javascript>alert('Hi.')</script>"; } but the function Buscar never show the alert but shows the $FechaMin I hopu u guys can help me out with this probem Thanks, Siddhartha I've followed the PHP Freaks pagination tutorial which you can find here. And I also got it to work, the only problem is that the script won't work when I use the query outside of the function. Here's the function: <?php function knuffix_list ($query, $dbc) { // find out how many rows are in the table: $query_row = "SELECT COUNT(*) FROM con"; $query_run = mysqli_query ($dbc, $query_row); $row = mysqli_fetch_row($query_run); $num_rows = $row[0]; // number of rows to show per page $rows_per_page = 5; // find total pages -> ceil for rounding up $total_pages = ceil($num_rows / $rows_per_page); // get the current page or set a default if (isset($_GET['current_page']) && is_numeric($_GET['current_page'])) { // make it an INT if it isn't $current_page = (int) $_GET['current_page']; } else { // default page number $current_page = 1; } // if current page is greater than total pages then set current page to last page if ($current_page > $total_pages) { $current_page = $total_pages; } // if current page is less than first page then set current page to first page if ($current_page < 1) { $current_page = 1; } // the offset of the list, based on current page $offset = (($current_page - 1) * $rows_per_page); echo "test " . $query; // SCRIPT ONLY WORKS IF I INSERT QUERY HERE $query = "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY contributed_date DESC LIMIT $offset, $rows_per_page"; $data = mysqli_query ($dbc, $query) or die (mysqli_error ($dbc)); // Loop through the array of data while ($row = mysqli_fetch_array ($data)) { global $array; // Variables for the table $con_id = $row['con_id']; $likes_count = $row['likes']; $dislikes_count = $row['dislikes']; $dbuser_name = $row['nickname']; $dbuser_avatar = $row['avatar']; $user_id = $row['user_id']; // The TABLE echo "<table padding='0' margin='0' class='knuffixTable'>"; echo "<tr><td width='65px' height='64px' class='avatar_bg' rowspan='2' colpan='2'><img src='avatar/$dbuser_avatar' alt='avatar' /></td>"; echo "<td class='knuffix_username'><strong><a href='profile.php?user=$dbuser_name' title='Profile of $dbuser_name'>" . $dbuser_name . "</a> ___ " . $user_id . "____ <form action='' method='POST'><button type='submit' name='favorite' value='fav'>Favorite</button></form>"; echo "</strong><br />" . $row['category'] . " | " . date('M d, Y', strtotime($row['contributed_date'])) . "</td></tr><tr><td>"; echo "<form action='' method='post'> <button class='LikeButton' type='submit' name='likes' value='+1'>Likes</button> <button class='DislikeButton' type='submit' name='dislikes' value='-1'>Dislikes</button> <input type='hidden' name='hidden_con_id' value='" . $con_id . "' /> </form></td><td class='votes'>Y[" . $likes_count . "] | N[" . $dislikes_count . "]</td></tr>"; echo "<tr><td class='knuffix_name' colspan='3'><strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>"; echo "<tr><td colspan='2' class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>"; echo "</table>"; // POST BUTTONS inside the table $likes = $_POST['likes']; $dislikes = $_POST['dislikes']; $con_id = $_POST['hidden_con_id']; $favorite = $_POST['favorite']; $array = array ($likes, $dislikes, $con_id, $user_id, $favorite); } /********* build the pagination links *********/ // BACKWARD // if not on page 1, show back links and show << link to go back to the very first page if ($current_page > 1) { echo " <a href='{$_SERVER['PHP_SELF']}?current_page=1'><<</a> "; // get previous page number and show < link to go to previous $prev_page = $current_page - 1; echo " <a href='{$_SERVER['PHP_SELF']}?current_page=$prev_page'><</a> "; } // CURRENT // range of number of links to show $range = 3; // loop to show links in the range of pages around current page for ($x = ($current_page - $range); $x < (($current_page + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $total_pages)) { // if we're on current page if ($x == $current_page) { // highlight it but don't make a link out of it echo "[<b>$x</b>]"; // if it's not the current page then make it a link } else { echo "<a href='{$_SERVER['PHP_SELF']}?current_page=$x'>$x</a>"; } } } // FORWARD // if not on the last page, show forward and last page links if ($current_page != $total_pages) { // get next page $next_page = $current_page + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?current_page=$next_page'>></a> "; // echo forward link for last page echo " <a href='{$_SERVER['PHP_SELF']}?current_page=$total_pages'>>></a> "; } /***** end building pagination links ****/ mysqli_close($dbc); } ?> As you can see above, the script will only work if I put the query right below the $offset variable and above the $data variable. I put the test echo above the query to see how the query looks like when I induce the query from the outside through the function parenthesis into the function, and this is what I get printed out: test SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY contributed_date DESC LIMIT , Obviously the $offset and the $rows_per_page variables are not set, when I induce the query from the outside into the function. So in that sense my question is: How can I induce the query from the outside into the function SO THAT the $offset and the $rows_per_page variables are set as well and NOT empty? p.s. I need the query outside of the function because I'm using a sort by category functionality. Hi I have a table class and functions I want to call in another function but can't get it working. Some help will be very welcome. It seesm that the new table class is not working in this function if I pass the values to it, I have tested the class, it does get the post values I post to it so $_POST['id'] are being received as well as all the other $_POST's but the table class and find function is not working, it works fine if I don't put it in a function.. function edit() { if (isset($error)){ $error.="Please fix the error(s) above";} else { if ($_POST['id'] <> "") { $update =& new table($db, 'publisher'); $update->find($_POST['id']); $update->name = $_POST['name']; $update->url = $_POST['url']; $update->contact = $_POST['contact']; $update->address = $_POST['address']; $update->phone = $_POST['phone']; $update->email = $_POST['email']; $update->save(); $error = "The Publisher has been edited"; } } } im using a function which connects to a db called 'comments' and then inside that function i again called another function that will connect to the db 'main' to get avatars.... but as i put Code: [Select] mysql_select_db("main") or die(mysql_error()); on the new function, the original function stops to fetch rows. i tried to remove "mysql_select_db("main") or die(mysql_error());" and used the new function to return some text only and it worked, so i guess the connection to the db was the problem... i tried doing Code: [Select] mysql_query("SELECT * FROM main.avatar INNER JOIN main.list ON main.avatar.title=main.list.id WHERE main.avatar.page_id='$id'"); but it also didnt work window.setInterval(function(){ s="<?= $lastid ?>"; $.post('../action/updatestream.php',{statusid:s.val()},function(e){ alert(e) }); }, 10000);Why isn't it working? Thanks, can you do that with php? Code: [Select] Database2() { function test($id) { $newdb = new Database2(); $newdb->test($id); } } Hello Everyone I have written a simple mail function to be emailed to a certain person on submission. On submission they would also like to have attachments sent to them. I got the email being sent but I can;t get the attachments to work. I have read several different examples and tutorials and none of them work. This is my code so far without any code for file attachment <?php $project_name = $_POST['project_name']; $needed = $_POST['date_needed']; $submitted = $_POST['date_submitted']; $department = $_POST['department']; $contact = $_POST['contact_person']; $extension = $_POST['extension']; $project_type = $_POST['project_type']; $published = $_POST['date_last_published']; $description = $_POST['description']; $color = $_POST['color']; $pdf = $_POST['pdf_needed']; $web = $_POST['web_needed']; $quanity = $_POST['quanity']; $email = "mdmartiny@sc4.edu"; $subject = "SC4 Graphics Design Service Request Form"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = "<html><body> <table width=\"100%\" border=\"0\" cellspacing=\"5px\" > <tr><td></td> <td>Project name: $project_name</td> <td></td> <td>Date needed by: $needed</td> </tr> <tr> <tr> <td></td> <td colspan=\"3\" align=\"left\" valign=\"top\"><strong><font size=\"+1\">Submitted to graphic designer</font></strong></td></tr> <tr><td height=\"25\"></td><td>Date $submitted</td><td>Department $department</td><td></td></tr> <tr><td height=\"25\"></td><td>Contact Person $contact</td><td>Extension $extension</td><td></tr> <tr><td height=\"25\"></td><td>Type of project $project_type</td><td colspan=\"2\">Approximate date of last publication $published</td></tr> <tr><td height=\"25\"></td><td colspan=\"3\">Project description/special instructions</td> <tr><td></td>><td colspan=\"3\">$description</td></tr> <tr><td height=\"25\"></td><td>Color $color</td><td>PDF needed $pdf</td><td>Website update needed $web</td></tr> <tr><td ></td><td>Estimated print quanity $quanity</td><td></td><td></td></tr> <tr> <td colspan=\"4\" align=\"left\" valign=\"top\"><hr height=\"5\"/> <strong><font size=\"+1\">Graphics office use only</font></strong></td> </tr> <tr> <td height=\"25\" width=\"2%\"> </td> <td width=\"34%\">Print Shop Color copier</td> <td colspan=\"2\">Print Vendor_______________________________________</td> </tr> <tr> <td height=\"25\"> </td> <td><strong><font size=\"+1\">Project tracking</font></strong></td> <td> </td> <td> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Received by graphic designer_______________________ Date _______</td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\"> <table width=\"100%\" height=\"35\"> <tr> <td>Approved by executive director__________ Date_________</td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td><tr> </table> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Completed and spell checked by graphic designer___________________________ Date__________</td> </tr> <tr> <td> </td> <td align=\"center\" colspan=\"3\"> <table cellpadding=\"10px\" cellspacing=\"0\" border=\"1\" width=\"100%\"> <tr bgcolor=\"#CCCCCC\"> <td> <table> <tr> <td> Proofread by marketing coordinator __________ Date__________</td> </tr> <tr> <td> Proofread by secretary __________ Date__________ </td> </tr> </table> </td> <td> <input type=\"checkbox\"> Revisions needed <br> <input type=\"checkbox\"> Revisions made ____ Date_____ </td> </tr> </table></td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td>Proofread by executive director______ Date______ </td><td><input type=\"checkbox\"> Revisions needed<br /> <input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td> Approval by requesting department __________ Date_________ <br /> <strong><font size=\"-1\">(Include all paperwork when returning)</font></strong></td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <td></td height=\"25\"> <td colspan=\"3\">Final approval by executive director _________________________________________ Date_________ </td> </tr> <tr> <td height=\"75\"></td> <td><input type=\"checkbox\"> Printed ____ Date _____</td> <td colspan=\"2\"><input type=\"checkbox\"> PDF created _____ Date _____<br /> <input type=\"checkbox\"> Website updated _____ Date _____</td> </tr> </table>"; $message .= "</body></html>"; mail($email, $subject, $message, $headers, "From: $email"); echo "The email has been sent."; ?> How can I call a public function inside of another public function? The get_primary_edge() says it's undefined, but it's just another public function in the class so shouldn't this work? Code: [Select] public function get_dynamic_edge($uid) { $uid = (int)$uid; $sql = "( SELECT `users`.`id` FROM partners INNER JOIN `users` ON `partners`.`user_id` = `users`.`id` WHERE partners.friend_id = '${uid}' AND `approved` = 1 ) UNION ALL ( SELECT `users`.`id` FROM `partners` INNER JOIN `users` ON `partners`.`friend_id` = `users`.`id` WHERE `partners`.`user_id` = '${uid}' AND `approved` = 1 )"; $result = mysql_query($sql) or die(mysql_error()); $i = 0; while (($row = mysql_fetch_assoc($result)) !== false) { $dynamic[$i] = array( 'uid' => $row['id'], 'score' => get_primary_edge($row['id']), ); $i++; } print_array($dynamic); } |