Jump to content

o3d

Members
  • Posts

    138
  • Joined

  • Last visited

    Never

Everything posted by o3d

  1. I'm not sure if this will work, but have a look at the query below, I added the "AND items..." section: SELECT * FROM items LEFT JOIN user_items ON items.item_id=user_items.item_id WHERE user_items.userid='$userid' AND items.item_id NOT IN ( SELECT primary_id FROM user_equipped_items WHERE userid='$userid' ) This will exclude all item_id's that is found in the user_equipped_items table. I'm also not sure if primary_id is the correct column? To come back to your original question on how to join, it gets complicated when you left join and then want to join another table to that table. Let me know if the above sql works, if not I'll rethink the query.
  2. Maybe try this: select * from dp, perso, center where dp.pid = perso.pid and center.pid = dp.pid order by dp.id asc Just remember that the same pid row data need to exist in all 3 tables else it won't work. Ps. try to use the sql keywords JOIN, etc when querying from multiple tables. It will save you a lot of debugging when you start working on larger queries: eg. select * from dp join perso on perso.pid = dp.pid join center on center.pid = dp.pid order by dp.id asc
  3. A very rough approach could be to put each <div class="data"> section into an array and then go through that array and find ITEMID. <?PHP $page_content_array = explode('<div class="data">', $page_contents); for ($i=0; $i<count($page_content_array); $i++) { $content_array = explode('/', $page_content_array[$i]); $content_array[5]; //this should contain the ITEMID for every <div class="data"> section } ?> this has not been tested
  4. o3d

    What is $i?

    $i, $j, $k, etc.. are used most frequently when looping through 'for' loops. I think it's just been adapted common practice over the years for easy reading.
  5. First off, are there any errors? Secondly check that your mail function returns with a true value. if (mail(...)) { header("Location: thankyou.php"); } else { echo 'could not send mail...<br />'; }
  6. date_default_timezone_set('Australia/Sydney'); http://nz2.php.net/manual/en/function.date-default-timezone-set.php
  7. To test wether a form or variable was submitted it is good practice to test with the following method: <?PHP if (isset($_GET['submit'])) { if (isset($_GET['score_1']) && $_GET['score_1'] != '' && isset($_GET['score_2']) && $_GET['score_2'] != '' && isset($_GET['score_3']) && $_GET['score_3'] != '') { if (do other checks ie. is_numeric... regexpr...) { //error echo "<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please restrict your input to only numbers.</b></font><br>"; } else { //good to continue $avg=($_GET['score_1'] + $_GET['score_2'] + $_GET['score_3'])/3; if ($avg >= 29) { $total = 0; else $total = ((29 - $avg) * (7/10)); print("The freegumpher handicap is:". $total); } } else { //error echo "<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Oops, you forgot to supply some information. Please correct the problem below.</b></font><br>"; } } ?>
  8. Maybe replace the textarea in the form with a static value e.g. <input type="text" value="test123" name="suggestion" /> and submit that and check the table.
  9. SELECT * FROM articles WHERE link='http://www.theage.com.au/travel/travel-news/nerd-bird-flies-like-a-brick-20100326-r0eh.html'; You forgot to close the string with a single quote.
  10. Once the user is logged in, I assume you populate a global variable or a session variable. Say e.g. $_SESSION['city_id']. Then you could do this: <?PHP if ($loggedin) { ?> <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> <select name="country"><option value="brazil" id="brazil">Brazil</option></select> <select name="city"><?PHP //loop through table of cities and check if city id == $_SESSION['city_id'] while () { echo '<option value="brazil" id="brazil" '.(city id == $_SESSION['city_id']?'selected':'').'>Brazil</option>'; } ?></select> <input type="submit" value="submit> </form> <?PHP } else { ?> <script> function show(){ if (document.form1.country.value == "Brazil") { document.getElementById('city').innerHTML = "<select name='mycity' id='mycity'><option value='ABC' id='ABC'>ABC</option></select>"; } } </script> <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> <select name="country"><option value="brazil" id="brazil" onchange="show()">Brazil</option> <div id="city"></div> <input type="submit" value="submit> </form> <?PHP } ?> Please know that this is just a concept and has not been tested and is psuedo-ish. Hope this put you on the right track.
  11. change <select name="country"><option value="brazil" id="brazil" onchange= onchange="show()">Brazil</option> to <select name="country"><option value="brazil" id="brazil" onchange="show()">Brazil</option> btw my suggestion won't fix your problem, i'm just pointing out a problem.
  12. Just so you know this will create problems if you use the same property in a tag more than once. It uses the first instance and ignore the rest. Remove the first "onchange=" occurance. <select name="country"><option value="brazil" id="brazil" onchange= onchange="show()">Brazil</option>
  13. If you have to use megauploads' captcha then you might have to do some curl'ing. However if you don't need to use their captcha this project might do the trick: http://www.phpcaptcha.org/
  14. I don't think these forums are there to do your work for you, it exists purely as a form of help. Some of the developers here don't have time to test their code and purely submit concepts. That error is really easy to fix and if you can't fix that then I would suggest to download "php for dummies".
  15. $position = strpos(file_get_contents('file/name'), $word); if (!position) { echo 'word not found'; }
  16. if (!mysql_query($query)) die('could not update row');
  17. http://php.net/manual/en/function.explode.php Explode takes a string delimited by specified characters and creates an array. Please be more specific in what you want to do.
  18. Just check if($found="1"){ Think it should be $found == "1"
  19. ... <!-- process sent data from form --> <?PHP if (isset($_GET['table_id'])) { $TmpEncVal = urldecode($_GET['table_id']); $DecVal = DecryptId($TmpEncVal); $sQuery = " delete from tbl_row where id = {$DecVal}"; //exec query... } ?> ... <!-- encrypt and show encrypted id on form --> <?PHP $EncVal = EncryptId(23); ?> <form> <input type="hidden" name="table_id" value="<?PHP echo urlencode($EncVal);?>"> <input type="submit"> </form> ...
  20. When you echo your encrypted id, parse it through the url_encode function. This value should appear on the form. Then when you want to use the value (as sent from the form) to delete items, you first have to url_decode, then decrypt the value and then use the decrypted value in the query.
  21. error_log your query. Then you might have to url_encode your encrypted value. Some characters might get 'scrambled' when sent via the browser. Thus you need to url_decode your value, decrypt it and then use it in your query. Hope that makes sense.
  22. how would i go about doing this in my above code? it sound more secure that way.. would i have to encrypt the ID on the view page where my delete button is linked to the delete.php page? Correct. check this out http://www.t4vn.net/tutorials/showtutorials/An-Introduction-to-Mcrypt-and-PHP.html
  23. Even if a user is logged in he/she will still be able to delete data. My advice is to echo the id on the form in encrypted format and then parsing that encrypted data along to php to decrypt e.g. delete.php?ID=e34cb4a32&db=tests That way users won't be able to guess an id.
  24. Simple google search returned this http://cutephp.com/forum/index.php?showtopic=35921
×
×
  • 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.