Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. Humm kinda confused as your echo doesn't match the posted code! <?php $query = "SELECT * FROM jos_users a LEFT JOIN jos_community_users b ON a.id = b.userid LEFT JOIN jos_community_fields_values c ON b.userid = c.user_id "; $where = ""; $where .= (empty($gender))?"":sprintf(" (c.field_id=2 and c.`value`='%s') OR",mysql_real_escape_string($gender)); $where .= (empty($cities))?"":sprintf(" (c.field_id=10 and c.`value`='%s') OR",mysql_real_escape_string($cities)); $where .= (empty($height))?"":sprintf(" (c.field_id=18 and c.`value`='%s') OR",mysql_real_escape_string($height)); $where .= (empty($build))?"":sprintf(" (c.field_id=19 and c.`value`='%s') OR",mysql_real_escape_string($build)); $where .= (empty($sexuality))?"":sprintf(" (c.field_id=20 and c.`value`='%s') OR",mysql_real_escape_string($sexuality)); $where .= (empty($lookingfor))?"":sprintf(" (c.field_id=21 and c.`value`='%s') OR",mysql_real_escape_string($lookingfor)); $where .= (empty($membertype))?"":sprintf(" (c.field_id=22 and c.`value`='%s') OR",mysql_real_escape_string($membertype)); $where .= (empty($activities))?"":sprintf(" (c.`value`='%s') OR",mysql_real_escape_string($activities)); $query .= (!empty($where))?"WHERE ".substr($where,0,-2):""; $query .= "GROUP BY a.id DESC "; $result = mysql_query($query) or die($query.mysql_error()); ?>
  2. If your going to build your query may I suggest this way! <?php $SQL = "SELECT * FROM jos_users a LEFT JOIN jos_community_users b ON a.id = b.userid LEFT JOIN jos_community_fields_values c ON b.userid = c.user_id WHERE "; $SQL .= (empty($gender))?"":sprintf(" (c.field_id=2 and c.`value`='%s') OR",mysql_real_escape_string($gender)); $SQL .= (empty($cities))?"":sprintf(" (c.field_id=10 and c.`value`='%s') OR",mysql_real_escape_string($cities)); $SQL .= (empty($height))?"":sprintf(" (c.field_id=18 and c.`value`='%s') OR",mysql_real_escape_string($height)); $SQL .= (empty($build))?"":sprintf(" (c.field_id=19 and c.`value`='%s') OR",mysql_real_escape_string($build)); $SQL .= (empty($sexuality))?"":sprintf(" (c.field_id=20 and c.`value`='%s') OR",mysql_real_escape_string($sexuality)); $SQL .= (empty($lookingfor))?"":sprintf(" (c.field_id=21 and c.`value`='%s') OR",mysql_real_escape_string($lookingfor)); $SQL .= (empty($membertype))?"":sprintf(" (c.field_id=22 and c.`value`='%s') OR",mysql_real_escape_string($membertype)); $SQL .= (empty($activities))?"":sprintf(" (c.`value`='%s') OR",mysql_real_escape_string($activities)); $SQL = substr($SQL,0,-2); $SQL .= "GROUP BY a.id DESC " ?>
  3. ahh missed one field_id=21 should be c.field_id=21 also change SELECT DISTINCT * , GROUP_CONCAT( DISTINCT value ) to SELECT *
  4. What table does field_id refer to ? try SELECT DISTINCT * , GROUP_CONCAT( DISTINCT value ) FROM jos_users a LEFT JOIN jos_community_users b ON a.id = b.userid LEFT JOIN jos_community_fields_values c ON b.userid = c.user_id WHERE (c.field_id=2 and c.`value`='$gender') OR (c.field_id=20 and c.`value`='$sexuality') OR (c.field_id=18 and c.`value`='$height') OR (c.field_id=19 and c.`value`='$build') OR (c.field_id=10 and c.`value`='$cities') OR (c.field_id=22 and c.`value`='$membertype') OR (field_id=21 and c.`value`='$lookingfor') OR (c.`value` = '$activities') GROUP BY a.id DESC
  5. Ahh MySQLi try this $db->execute(); $db->store_result(); $db->bind_result($Username); //bind result $db->fetch(); //fetch row echo $Username; //display
  6. MadTechie

    Add a space

    Well 3:00am is my normal time, any later and I find it hard to get up for work at 8:40am.. of course i have a lay ins as well! I just code better at night
  7. MadTechie

    Add a space

    I'm not sure but mb_convert_kana() may help you out I'm jumping ship for a bit (Its 4:30am my bed time)
  8. Meah.. you get used to it, infect I make less mistakes as I'm used to sprintf() ing my queries
  9. when you fetch the row it will be empty.. (sorry its 4:30am my bed time)
  10. MadTechie

    Add a space

    try this if (preg_match('/^[\p{Katakana}\x8140]+$/iu', $subject)) { \p{Hiragana} exists Kanji .. i don't think so!
  11. try $config['basedir'] = ''; or $config['basedir'] = '/';
  12. The code for randomad.php is kinda simple, I decided to make a better version while keeping the ad file the same. <?php /* Please note for using more than one add per page your need to give each ad a unqiue ID (see the ?ID=x) You can also add a lifespan but adding &life=x this mean that THIS advert space will not that the same advert got X turns (see third example) */ /* SAMPLE <iframe marginwidth="0" marginheight="0" width="468" height="60" scrolling="no" frameborder=0 src="randomad.php?ID=Top"></iframe> <iframe marginwidth="0" marginheight="0" width="468" height="60" scrolling="no" frameborder=0 src="randomad.php?ID=Left"></iframe> <iframe marginwidth="0" marginheight="0" width="468" height="60" scrolling="no" frameborder=0 src="randomad.php?ID=Right&life=10"></iframe> */ $adfile = "ads.txt"; //Add file header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); session_start(); // load the file that contain the ads $ID = (int)(!empty($_GET['ID']))?$_GET['ID']:1; $ads = file(dirname(__FILE__)."/$adfile"); if(isset($_SESSION["Ad"]) && is_array($_SESSION["Ad"])) { foreach(array_keys($_SESSION["Ad"]) as $saveAd) { unset($ads[$_SESSION["Ad"][$saveAd]['Display']]); if($_SESSION["Ad"][$saveAd]['Life']==0) { unset($_SESSION["Ad"][$saveAd]); } if($saveAd == $ID) $_SESSION["Ad"][$saveAd]['Life']--; } } array_unique($ads);//Remove identcial Ads $_SESSION["Ad"][$ID]['Display'] = array_rand($ads); $_SESSION["Ad"][$ID]['Life']=(int)(!empty($_GET['life']))?$_GET['life']:count($ads); echo $ads[$_SESSION["Ad"][$ID]['Display']]; ?>
  13. You could pre-filter and replace anything that's not a [0-9a-z] with a % and use then use LIKE
  14. This won't help per system but per script it will <?php $used = memory_get_usage();//used by this script $total = ini_get('memory_limit');//total a script can use! $remain = $total - $used;//Remaining ?>
  15. Some row in the child does not comply with the constraint, to correct this problem. You find the rows like this: select child.id from child left join parent on (child.parent_id=parent.id) where child.id is not null and parent.id is null;
  16. MadTechie

    Add a space

    Tip#1 use \p{Katakana} ie <?php $subject = "アイ"; //<-- forum doesn't like Katakana in code lol if (preg_match('/^\p{Katakana}+$/iu', $subject)) { echo "ok"; } else { echo "failed"; } ?>
  17. Your just add another ? and another bind if ($db = $this->Connection->prepare("SELECT * FROM Users WHERE Id=? AND Group=?")) { $db->bind_param("s", $this->ID); $db->bind_param("s", $this->Group); or you can use an array $db->prepare($conn, 'SELECT * FROM Users WHERE Id=? AND Group=?'); $result = $db->execute($db, array($this->ID, $this->Group)); but it really depends on what your using
  18. isn't it from the top level http://help.godaddy.com/article/1361 if not try wwwroot or public_html
  19. depends on the class, but at a guess your still need fetch them ie while ($row = $db->fetch_row()) { var_dump($row[0]); } whats the Connection function ?
  20. Theirs reasons for storing it in a blob and reasons not to store it in a blob, personally (and most agree) I wouldn't store it in a blob, but theirs exceptions to every rule.. Can you test the images (just move a test one to a public area and view it)
  21. Okay the problem with the delete code (see comments) <?php //delete checked if (isset($_POST['deleteChecked'])){ $query = "SELECT * FROM info"; $result = mysql_query($query); $count = mysql_num_rows($result); for ($i=0;$i<$count;$i++){ $del_id[$i] = $_POST['checkbox[]']; //Nope the [] make it an array $sql = "DELETE FROM info WHERE id='del_id'"; //del_id should be $del_id $result = mysql_query($sql); } } ?> okay heres how your fix your code <?php foreach($_POST['checkbox'] as $del_id) { $sql = "DELETE FROM info WHERE id='$del_id'"; $result = mysql_query($sql); } } ?> BUT this is a better way. as it only uses 1 SQL call <?php //delete checked if (isset($_POST['deleteChecked'])){ /*better option*/ $CB = implode(",",$_POST['checkbox']); $query = "DELETE FROM info WHERE id IN ($CB)"; $result = mysql_query($query); } ?>
  22. $table isn't being set.. what table are you searching ?
  23. And the winner gets to fight a Puggle Dog
  24. I'm rooting for the Polar Bear, drag that Kodiak under water and kick its arse!
  25. I was testing 7 = July in anycase solved
×
×
  • 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.