Jump to content

EmlynK

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

About EmlynK

  • Birthday 10/08/1991

Profile Information

  • Gender
    Male

EmlynK's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You could try: $query =mysql_query ("INSERT INTO customers (firstname, lastname, doornumber, street, town, postcode, useremail, telephone) VALUES('$firstname', '$lastname', '$doornumber', '$street', '$town', '$postcode', '$useremail', '$telephone') ") Not sure if it would work though....
  2. Ahh, this is much better than my suggestion. A lot less lines of code needed for the selection of vendors. I didn't think about using a loop. doh.
  3. You could try something like this, but I'm not sure if it would work: function num_rows($id) { if($id <= 0) { $vendors = ("SELECT * FROM vendors"); } else { $vendors = ("SELECT * FROM vendors WHERE vendor_type_id = ". abs(@intval($id)) .""); } $num_vendors = mysql_num_rows($vendors); print $num_vendors; } ?> <p>AV / Tech / Production - <? num_rows(1); ?><br /> Bakeries / Cakes - <? num_rows(2); ?><br /> Bridal Services - <? num_rows(3); ?><br /> Caterers / Food Service - <? num_rows(4); ?><br /> Destination Management - <? num_rows(5); ?><br /> DJs / Entertainment - <? num_rows(6); ?><br /> Event Management - <? num_rows(7); ?><br /> Event Rentals / Tents - <? num_rows(; ?><br /> Florists / Flowers - <? num_rows(9); ?><br /> Health / Beauty - <? num_rows(10); ?><br /> Printing / Marketing - <? num_rows(1); ?><br /> Photographers - <? num_rows(11); ?><br /> Transportation / Valet - <? num_rows(12); ?><br /> Tuxes / Formal Wear - <? num_rows(1); ?><br /> Videographers - <? num_rows(13); ?><br /> Wedding Officiants - <? num_rows(14); ?> </p> <p><strong>Total Vendors - <? num_rows(0); ?></strong></p>
  4. I've worked out a much easier way now. 13 lines of code instead of over 25. BUT, could someone please, if possible, explain to me why my original function didn't work? Thank you.
  5. I'm creating my own lottery feature for my online game, which uses in-game money. I decided to create my own function to compare the numbers of each ticket. Before I started creating the mod, I did some testing to see if my pseudocode function would work. When I go onto my test page, I get this error: Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error. I've Googled it, and it says that it's a Google Chrome error and that I should restart my browser and so on, which I did. Nothing worked. I've yet to try it in another browser yet..... My code is below: <?php include_once(DIRNAME(__FILE__) ."/globals.php"); ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); function checkResult($numbers, $winNums, $key, $wins) { if($key >= 7 && $wins >= 7) { print "Break out <br />"; return $correct; break; } else { $nums = unserialize($numbers); $winning = unserialize($winNums); $p = $nums[$key]; $n = $winning[$wins]; if($n != $p && $n > $p) { print "Increment \$key <br />"; $key++; checkResult($numbers, $winNums, $key, $wins); } elseif($n != $p && $n < $p) { print "Increment \$wins <br />"; $wins++; checkResult($numbers, $winNums, $key, $wins); } elseif($n === $p) { print "Matching! <br />"; $correct++; $key++; $wins++; checkResult($numbers, $winNums, $key, $wins); } } } $yourNumbers = array(15,20,42,37,4,; $winNumbers = array(17,28,20,4,15,39); $sortYourNumbers = sort($yourNumbers); $sortWinNumbers = sort($winNumbers); print_r($yourNumbers); print "<br />"; print_r($sortYourNumbers); print "<hr />"; print_r($winNumbers); print "<br />"; print_r($sortWinNumbers); $yrs = serialize($yourNumbers); $wns = serialize($winNumbers); $correct = 0; print "<br />"; print $yrs ."<br />"; print $wns; checkResult($yrs, $wns, 0, 0); $h->endpage(); ?> Could someone please point out to me why this is causing the unknown error? I've tried other pages on my website, they all work perfectly. Any help will be appreciated.
  6. Ahh, thank you for pointing that out. I hadn't realised that. You learn something new every day.
  7. You could put all the characters into an array: $characters = array("'","\"",";",":",".",">",",","<","-","_","(",")","*","&","^","%","$","#","@","!","\\","|","/","?"); And then use a foreach loop to run through each one, replacing them with "" using str_replace().
  8. Thanks for more info, it's a lot clearer now. For question B2, you could use: $output = ""; $total = 0; for($i = 1; $i <= 3; $i++) { $num = rand(1,3); if($num == 1) { $output .= "A"; } elseif($num == 2) { $output .= "B"; } else { $output .= "C"; } $total = $total + $num; // or you could have $total += $num; } print $output; Then the 50 word one doesn't require much edit. Put another FOR loop around the code above, but using 50 instead of three and add a check to see if the output is equal to "ABC" and increment a counter using $counter++; or $counter += 1; or $counter = $counter + 1; Include the above bit after the 2nd FOR loop. I hope that helps.
  9. Correct me if I'm wrong, but shouldn't the number generated be random? By what Nightslyr has done, the outcome will always be "ABC". For the second task, you will need to generate a random number between 1 and 3 using mt_rand(1,3) or any other function you prefer, and then use the IF statements. And then a final IF statement to see if the string is "ABC" and increment the ABC counter.
  10. You're very welcome. I'm glad it worked.
  11. You could try this: $accountTypes = array("internal admin","super admin"); if(!in_array($_SESSION['account_type'], $accountTypes)) { die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } That should effectively do the same thing. Let us know if it works, please?
  12. If only I signed up a day earlier! But I'm glad you managed to solve it. And you're welcome.
  13. You could use the expode() function to split the string into an array: $string = explode(",", $yourstring); $city = $string[0]; $state = $string[1]; $country = $string[2]; And then search for each one in the DB by using the $city, $state, $country variables. This could be one way of doing it.
×
×
  • 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.