Jump to content

KrisNz

Members
  • Posts

    271
  • Joined

  • Last visited

Everything posted by KrisNz

  1. email me an export file of the relevant tables if you like so I can try it out...
  2. This will do it, there may be a more elegant, mathematical solution, but I suck at math. <?php $randNums[] = mt_rand(1,100); $i=1; while ($i<=3) { $test = mt_rand(1,100); $items = range($test - 4,$test+4); $a = array_intersect($randNums,$items); if (empty($a)) { $randNums[] = $test; ++$i; } else { echo "<p>$test was too close</p>"; } } print_r($randNums); ?>
  3. You're going to get a blank page since your script doesn't echo anything out. As for why your mail isn't sending its hard to say. try echoing out $m->ErrorInfo; after you send.
  4. get a copy of phpmyadmin, then upload it to your server. You'll need to set up the config file with the appropriate username and password but once you get that going, you'll be able to use that to backup all your databases.
  5. this //you've closed your select tag and the select tag doesn't have a value attribute, only the options inside it do <select id="approved" name="approved[$raceID]" style="WIDTH: 50px" value ="" /> <option $yesSelected value="Yes">Yes</option> <option $noSelected value="No">No</option> should be <select id="approved" name="approved[$raceID]" style="WIDTH: 50px"> <option $yesSelected value="Yes">Yes</option> <option $noSelected value="No">No</option> </select>
  6. How are you retrieving said number? I don't see any reference to $_POST
  7. The reason this didn't work... if ($result['Colour'] = 'blue') Is because you've assigned a value rather than compared two values. use == Also heres a sample that might be helpful <?php //sql select * from fruits_n_veges $dbData[0] = array("color"=>"green","name"=>"apple","type"=>"fruit"); $dbData[1] = array("color"=>"yellow","name"=>"lemon","type"=>"fruit"); $dbData[2] = array("color"=>"green","name"=>"broccoli","type"=>"vegetable"); $dbData[3] = array("color"=>"yellow","name"=>"sweetcorn","type"=>"vegetable"); $allMyFruitsNVeges = array(); //sort results into one multi-dimensional array organized by color foreach ($dbData as $item) { $allMyFruitsNVeges[array_shift($item)][] = $item; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en"> <head> <title><!-- Insert your title here --></title> </head> <body> <pre> <?php print_r($allMyFruitsNVeges);?> </pre> <div id="Box1" style="border:1px solid green;margin-bottom:1em;"> <h3>Greens</h3> <?php foreach ($allMyFruitsNVeges['green'] as $aDetails) :?> <p><?php echo "name is {$aDetails['name']}" ?></p> <p><?php echo "type is {$aDetails['type']}" ?></p> <?php endforeach;?> </div> <div id="Box2" style="border:1px solid yellow;"> <h3>Yellows</h3> <?php foreach ($allMyFruitsNVeges['yellow'] as $aDetails) :?> <p><?php echo "name is {$aDetails['name']}" ?></p> <p><?php echo "type is {$aDetails['type']}" ?></p> <?php endforeach;?> </div> </body> </html>
  8. You have a typo for starters, else if($datbase->emailTaken($subemail)){ Plus you'll have to do a global $database; inside the function(register) you're trying to use your database class in. Making it global outside of the class might work too, I'm not sure, I never use globals.
  9. I'm not quite sure how to explain this thoroughly but suffice it to say that's not how include works. When you include monkey.php in index.php, monkey.php will have access to the all the variables,functions etc that exist in index.php. You don't need to "pass" it anything.
  10. <?php // here, we check if the form has been submitted, because we need to handle // redirection before we handle outputting the HTML stuff. if (isset($_POST['submitted'])) { if (empty($_POST['displayname']) || empty($_POST['displaytype']) || empty($_POST['description']) || empty($_POST['address']) || empty($_POST['city']) || empty($_POST['state']) || empty($_POST['postal']) || empty($_POST['country']) || empty($_POST['imagefile'])) { $error = 'Please fill in all fields.'; // here, they have not filled in all fields. Set an error. } else { // MAKE CONNECTION include ('db_connect.php'); $displayname = $_POST['displayname']; $displaytype = $_POST['displaytype']; $description = $_POST['description']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $postal = $_POST['postal']; $country = $_POST['country']; $website = $_POST['website']; $imagefile = $_POST['imagefile']; mysql_query("INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website, imagefile) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website', '$imagefile')")or die (mysql_error()); } } ?>
  11. I mean that a) the code that runs the insert query isn't inside any condition, its always going to be executed. b) CUT from // MAKE CONNECTION down to (but not including!) ?> and Paste after this : else { c) change if (isset($_POST['submit'])) { //TO if (isset($_POST['submitted'])) //this is the name of your submit button
  12. Your code looks like its going to insert a record every time the page loads?!? The code that does the inserting should be in that empty else{} block you have.
  13. SET approved = '$approved' should be SET approved = '$yesOrNo'. Does the foreach loop get executed when you submit the form? do $raceID and $yesOrNo hold their expected values?
  14. foreach($_POST['travelinc'] as $value) { $travelinc .= " $value, "; } That could give you problems if you have register_globals on. try $user_travelinc_choices = implode(",",$_POST['travelinc']); That will give you a comma separated string to insert into a db field.
  15. its because you have it in single quotes which treats everything inside it as a literal string. it should be header( "Location: $redirect" ) ;
  16. Does this help, obviously i cant test it <?php global $scripturl , $context; //process postback if (isset($_POST['submitted']) and isset($_POST['approved'])) { //approved should be an array so you can update all your different records #$approved = mysql_real_escape_string($_POST['approved']); if (is_array($_POST['approved'])) { foreach ($_POST['approved'] as $raceID => $yesOrNo) { mysql_query ("UPDATE race_table SET approved = '$approved' WHERE raceID = '$raceID'") or die ("Could not execute query"); } } } //show the tables, what is $GET['page']??? it seems like this just posts back to the same //page so just make action="" echo' <a href="http://vsk-ayc.totalh.com/index.php?page=221">RETURN TO THE START PAGE</a><br> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <tr class ="catbg"> <td width = "100%">Recent Race Reports:</td> </tr> </table> <form action="'.$scripturl.'?page=221'.$GET['page'].'" method="post"> <input id="submitted" name="submitted" type="hidden" value="TRUE" />'; $raceq = "SELECT race_table.raceID, race_table.raceDate, race_table.hostName, race_table.boatsInRace, race_table.seriesID, series_table.seriesName, race_table.factor , race_screenshots_table.imageURL, race_table.approved FROM race_table LEFT JOIN series_table ON race_table.seriesID = series_table.seriesID LEFT JOIN race_screenshots_table ON race_table.raceID = race_screenshots_table.raceID ORDER BY raceID DESC;"; $result = mysql_query($raceq); while($row = mysql_fetch_array($result)) { $raceID = $row['raceID']; echo '<br /> <table class="bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <tr class ="catbg"> <td>Race ID:</td> <td>Date:</td> <td>Host Name:</td> <td>Boats:</td> <td>Series Name:</td> <td>Factor</td> <td>Image URL:</td> <td>Approved</td> </tr> <tr class="catbg4"> <td width="10%">' . $row['raceID'] . '</td> <td width="10%">' . $row['raceDate'] . '</td> <td width="20%">' . $row['hostName'] . '</td> <td width="10%">' . $row['boatsInRace'] . '</td> <td width="20%">' . $row['seriesName'] . '</td> <td width="5%">' . $row['factor'] . '</td> <td width="20%"> <a href="javascript:void(window.open(\'' . $row['imageURL'] .'\',\'\',\' resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no, fullscreen=no,dependent=no,width=1024,height=768\'))">VIEW IMAGE</a></td>'; $noSelected = 'selected="selected"'; if ($context['allow_admin'] AND $row['approved'] != "Yes") { $yesSelected =$noSelected; $noSelected = ''; //echo out the drop down box for this raceID - notice that its an array //using the unique id of the race as the key echo<<<EOF <td width = "5%"> <select id="approved" name="approved[$raceID]" style="WIDTH: 50px" value ="" /> <option $yesSelected value="Yes">Yes</option> <option $noSelected value="No">No</option> </td> </tr> </table> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <TR class ="windowbg3"> <td width = "20%">Skipper Name</td> <td width = "20%">Position</td> <td width = "20%">Race Points</td> <td width = "20%">Match Points</td> <td width = "20%">Fleet Points</td> </tr> </table>; EOF; } else echo' <td width = "5%">' . $row['approved'] . '</td> </tr> </table> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <TR class ="windowbg3"> <td width = "20%">Skipper Name</td> <td width = "20%">Position</td> <td width = "20%">Race Points</td> <td width = "20%">Match Points</td> <td width = "20%">Fleet Points</td> </tr> </table>'; $ptsq = "SELECT race_table.raceID , pts_table.skipperName, pts_table.position, pts_table.racePoints , pts_table.matchPoints , pts_table.fleetPoints FROM pts_table LEFT OUTER JOIN race_table ON pts_table.raceID = race_table.raceID WHERE race_table.raceID = '$raceID' GROUP BY pts_table.skipperName, race_table.raceID ORDER BY race_table.raceID, pts_table.racePoints DESC LIMIT 0 , 30;"; $result2 = mysql_query($ptsq); while($row2 = mysql_fetch_array($result2)) { echo' <TABLE class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <TR class ="windowbg3"> <TD width = "20%">' . $row2['skipperName'] . '</td> <TD width = "20%">' . $row2['position'] . '</td> <TD width = "20%">' . $row2['racePoints'] . '</td> <TD width = "20%">' . $row2['matchPoints'] . '</td> <TD width = "20%">' . $row2['fleetPoints'] . '</td> </tr> </table>'; } } //end of loop if ($context['allow_admin']) { echo' <br> <table class = "bordercolor" cellSpacing="1" cellPadding="1" width="100%" border="0"> <tr class ="catbg"> <td>Submit Approvals:</td> </tr> </table> <br> <table> <tr> <INPUT type="submit" value="Submit"><INPUT type="reset" value="Reset"> </tr> </table>'; } echo ' </form>'; ?>
  17. try $pdf->MultiCell(0,5, $travelinc[$i] . ", ",0,0);
  18. $userInput = 'www.google.com'; //strpos way (faster) $pos = strpos($userInput,"http://"); if ($pos !== 0) { echo "you didnt enter http://"; } //regex way if (!preg_match("/^http:\/\//",$userInput)) { echo "you didn't enter http://"; }
  19. Yes, but you might as well make it part of the first condition... if (isset($_POST['submitted']) and isset($_POST['approved'])) {
  20. are you sure you weren't reading about mkdir()?? echo dirname($_SERVER['PHP_SELF']);
  21. while (isset($_POST['approved'])) Wont this cause an infinite loop??? Where are you unsetting $_POST['approved']. Actually you should just get rid of that while bit altogether (not the code between the braces obviously)
  22. Well, you can test whether $line has anything in it - (it could just be the empty line at the bottom of the file) before you try and operate on it but you're still going to run into problems with multiple line comments in your textarea. They're going to be written to the file with all the line breaks preserved. Also what if someone types a '|' in the textarea? You're better off using some obscure delimiter like chr(254). Then again you're better off using mysql or something
  23. Well, cURL can impersonate a browser if thats helpful.... curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); But what exactly doesn't work? Try adding something like this to the top of your script so that you can see any errors when its run on your sms server. error_reporting(E_ERROR); ini_set('error_log', '/some/writable/path/errorlog');
  24. I highly recommend using jpGraph. Their documentation and examples will help you do whatever you want, its very easy to use.
×
×
  • 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.