Jump to content

mjohnson025

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by mjohnson025

  1. Hi everyone. I am doing some studying for the Zend certification. I came across this question: 'What will the following script output?' <?php $array = array(1, 2, 3, 5, 8, 13, 21, 34, 55); $sum = 0; for ($i = 0; $i<5; $i++){ $sum += $array[$array[$i]]; } echo "<br/>". $sum; ?> The answer is 78, and the explanation was less than helpful for me, as I struggled to understand what they were saying. Can anyone here put it into simpler terms? Here is their explanation: 'If you step through the code manually, you'll find that , when $i is zero, then $array[$array[$i]] becomes $array[$array[0]], or $arrray[1], that is 2.' I think I get it, sort of, but if someone could give a better explanation I would be much appreciative. Thanks, Mike
  2. Hi all! I have a page that is used to manage multiple user requests. The problem that I am having, is that it is supposed to send an email to the reporter any time their request is updated from this page. This works fine as long as I am doing one at a time, but when I try to update multiple records it doesn't send the emails. (All other functionality is working fine though.) Here is a summary of what I have so far: The form field to pass the users' emails <input type="hidden" name="user_email<?= $arrValues["mantis_bug_id"] ?>" id="user_email<?= $arrValues["mantis_bug_id"] ?>" value="<?=$arrValues["email"]?>" /> This gets passed, along with the rest, to an update case on the same page, where I use a foreach() to process the multiple records: foreach($_POST['chkResult'] as $intBugID){ . . . . . if (isset($_POST["user_email$intBugID"])){ $emailTo = $_POST["user_email$intBugID"]; $emailSubject = "Mantis issue $intBugID has been modified."; $emailContent = "Mantis issue $intBugID has recently been modified. Please review the changes that have been made here [link]</a><br />If you have any questions or concerns regarding this issue, please contact Mike or Matt.<br />Thank you,<br />The IT Team."; include_once("{$_SERVER['DOCUMENT_ROOT']}/includes/Email.class.php"); $email = new Email(); $email->ContentType = "text/html"; $email->From = "me@myemail.org"; $email->FromName = "MOPS Mantis Bugtracker"; $email->to($emailTo); $email->bcc('me@myemail.org'); $email->subject($emailSubject); $email->setBody($emailContent); $email->send; echo 'User: ' . $emailTo. '<br />'; echo "User Email: " . $emailTo. "<br /><br />"; } }//end foreach As I said, this all works fine when I'm processing one issue at a time, but not when doing multiples. All other actions in the foreach() are also working. You'll notice that I'm echoing the username and email at the end for debugging purposes. The interesting thing is, that will output all of the correct usernames and emails for each user, it's just that the $email->send; just isn't working. Needless to say, this has become quite a frustrating bug to fix. Any help at all is much appreciated! Thanks, Mike
  3. thanks, I also figured out that $DBconnect->fetch_row() should have been $result->fetch_row() since it was the newest object. Thanks for your help! Mike
  4. Greetings all- I keep getting a fatal error: call to undefined method for mysqli::fetch_row() on line 15. Can anyone help me figure out what's wrong? Any help will be appreciated! Thanks, Mike <?php $table_contents = ""; $DBconnect = @new mysqli("localhost", "root", "gotham"); if (mysqli_connect_errno()) die("<p>Unable to connect to the server." . "Error Code " . mysqli_connect_errno() . ": " . mysqli_connect_error()) . "</p>"; $DBName = "cwb208"; @$DBconnect->select_db($DBName) or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBconnect) . ": " . mysqli_error($DBconnect)) . "</p>"; $sql = "select state_code, count(*) from regusers group by state_code order by 2 "; $result = $DBconnect->query($sql) //or die("<p>Unable to execute the query.</p>" . "<p>Error Code " . $DBconnect->errno . ": " . $DBconnect->error) . "</p>"; or die ("MySQL Error! SQL: $sql, Error: " . mysqli_error($DBconnect)); $row = $DBconnect->fetch_row($result); //or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBconnect) . ": " . mysqli_error($DBconnect)) . // "</p>"; while ($result) { $table_contents .= "<tr>" . "<td>" . trim($row[0]) . "</td>" . "<td>" . trim($row[1]) . "</td>" . "</tr>"; $row = $DBconnect->fetch_row($result); } $DBconnect->close(); ?> <html> <head> <title>CP11 Summary Report</title> </head> <body> <h2>Counts By State</h2> <table border="1" summary=""> <tr> <td>US State</td> <td>Count</td> </tr> <?php echo $table_contents; ?> </table> </body> </html>
  5. thanks. I guess my eyes just needed a rest. I forgot a closing " a couple lines before. Thanks for your help! Mike (I'll pay closer attention to where i post in the future)
  6. Hi everyone! My eyeballs seem not to be working. I keep getting the following error: Parse error: syntax error, unexpected '>' in C:\Documents and Settings......\UserRegistrationPart2.php on line 31 here is the line it's talking about: echo "<p><strong>Name</strong>: {$Row[0]}<br /> "; If someone could tell my what i might be missing, i would greatly appreciate it. <frustrated!> :-) Mike
  7. just another note on the difference with $_POST and $_GET to piggyback on what Barand said: You'll find that the more sensitive the information is on the server, you'll want to use $_POST; it's a little more secure. (At least that's how it was taught to me )
  8. That function is the type of thing I was looking for. I was trying to figure out how to convert the value. Does $letter need to be initialized elsewhere?
  9. Yes, this is what I ended up doing, which does work, just not very efficient if I need to add more options. //test if playerChoice is X if ($playerChoice == "X" && $cpu_Choice == "X") { $result = "PUSH!"; } elseif ($playerChoice == "X" && $cpu_Choice == "Y"){ $result = "LOSES TO"; } elseif ($playerChoice == "X" && $cpu_Choice == "Z"){ $result = "BEATS"; } //test if playerChoice is Y if ($playerChoice == "Y" && $cpu_Choice == "X") { $result = "BEATS"; } elseif ($playerChoice == "Y" && $cpu_Choice == "Y"){ $result = "PUSH!"; } elseif ($playerChoice == "Y" && $cpu_Choice == "Z"){ $result = "LOSES TO"; } //test if playerChoice is Y if ($playerChoice == "Z" && $cpu_Choice == "X") { $result = "LOSES TO"; } elseif ($playerChoice == "Z" && $cpu_Choice == "Y"){ $result = "BEATS"; } elseif ($playerChoice == "Z" && $cpu_Choice == "Z"){ $result = "PUSH!"; }
  10. ok, so i used a bunch of if and elseif statements to figure it out and it worked, but if anyone knows of a simpler answer that would be very helpful! Mike
  11. Hi all! I was wondering if anyone could help me figure out how to define and compare values of one variable to another. For example, I am making a game where the player makes a choice (x,y,z) and cpu makes a choice from the same options. I am trying to define x > z but x < y, and so on. As always, any help greatly appreciated! Thanks, Mike
  12. thanks for everyone's help! I really appreciate it! Mike
  13. reading it it looks like it should work, but something's not quite right. I don't understand the reasoning for the array_merge. I also am not sure which variable is returning the information I need to print to the screen (50's = 1, 20's = 0, 10's = 1, etc..) I really appreciate your help! Mike
  14. Hi all, I'm having a very difficult time figuring out how to make the program determine the proper bills for this project. I've got it showing me the change, but i need to make is seperate it into 50, 20, 10, etc.. Can anyone give me an idea of where to start?? Thanks, Mike Here is what i have so far. (So nobody thinks i'm being lazy.) :-) <?php if (isset($_GET['cost']) && isset($_GET['paid'])){ if (is_numeric($_GET['cost']) && is_numeric($_GET['paid'])){ $cost = $_GET['cost']; $paid = $_GET['paid']; $formattedCost = number_format($cost,2); $formattedPaid = number_format($paid,2); echo "<p>\$" . $formattedCost . "\n</p>"; echo "<p>\$" . $formattedPaid . "\n</p>"; $change = $formattedPaid - $formattedCost; echo "<p>\$" . $change . "\n</p>"; } else echo "<p>You must enter a numeric value!</p>"; } ?>
  15. thank you so much! i've been looking to deep into the problem!
  16. hello all. I am trying to break up a single word and basically flip it to create a new word in order to test the two strings. (looking for palindromes) I've thought about using str_split, but then how would i put it back together the other way? any help would be greatly appreciated! Mike
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.