Newbie Posted February 1, 2012 Share Posted February 1, 2012 Ok basicly iam having problems with this part of an search mod file is called searchdo.php <?php include "globals.php"; $_POST['search'] = mysql_real_escape_string($_POST['search']); $_POST['save'] = mysql_real_escape_string($_POST['save']); $_POST['clear'] = mysql_real_escape_string($_POST['clear']); if($_POST['search']) { $_POST['moneymin'] = abs(@intval($_POST['moneymin'])); $_POST['daysmax'] = mysql_real_escape_string($_POST['daysmax']); $_POST['daysmin'] = mysql_real_escape_string($_POST['daysmin']); $_POST['levelmin'] = abs(@intval($_POST['levelmin'])); $_POST['levelmax'] = abs(@intval($_POST['levelmax'])); $_POST['id'] = mysql_real_escape_string($_POST['id']); $_POST['location'] = abs(@intval($_POST['location'])); $_POST['name'] = mysql_real_escape_string($_POST['name']); $levelmin_clause="WHERE level >= {$_POST['levelmin']}"; $levelmax_clause=" AND level <= {$_POST['levelmax']}"; $id_clause=($_POST['id']) ? " AND userid LIKE('%{$_POST['id']}%')" : ""; $name_clause=($_POST['name']) ? " AND username LIKE('%{$_POST['name']}%')" : ""; $location_clause=($_POST['location']) ? " AND location LIKE('{$_POST['location']}')" : ""; $online_clause=($_POST['online']) ? " AND laston >= unix_timestamp()" : ""; $daysmin_clause=($_POST['daysmin']) ? " AND daysold >= {$_POST['daysmin']}" : ""; $daysmax_clause=($_POST['daysmax']) ? " AND daysold <= {$_POST['daysmax']}" : ""; $moneymin_clause=($_POST['moneymin']) ? " AND money > {$_POST['moneymin']}" : ""; $q=$db->query("SELECT * FROM users $levelmin_clause$levelmax_clause$id_clause$name_cl ause$location_clause$online_clause$daysmin_clause$ daysmax_clause$moneymin_clause",$c); print " <table width='75%' cellspacing='1' class='table'><tr><th><h3>User Search Results</h2></th></tr></table>"; print"<table width='75%'><tr><td colspan='5'>";print mysql_num_rows($q)." Users found. </td></tr><tr class='table'><th>User</th><th>Level</th><th>Money</th><th>Mug</th><th>Attack</th></tr>"; while($r=mysql_fetch_array($q)) { print "<tr><td><a href='viewuser.php?u={$r['userid']}'>"; print" {$r['username']}"; print"</a></td><td>{$r['level']}</td><td>\${$r['money']}</td><td><a href='mug.php?ID={$r['>[Mug]</a></td><td><a href='attack.php?ID={$r['>[Attack]</a></td></tr>"; } print "</table>"; } else if($_POST['save']) { $_POST['moneymin'] = abs(@intval($_POST['moneymin'])); $_POST['daysmax'] = mysql_real_escape_string($_POST['daysmax']); $_POST['daysmin'] = mysql_real_escape_string($_POST['daysmin']); $_POST['levelmin'] = abs(@intval($_POST['levelmin'])); $_POST['levelmax'] = abs(@intval($_POST['levelmax'])); $_POST['id'] = mysql_real_escape_string($_POST['id']); $_POST['location'] = abs(@intval($_POST['location'])); $_POST['name'] = mysql_real_escape_string($_POST['name']); $levelmin_clause="WHERE level >= {$_POST['levelmin']}"; $levelmax_clause=" AND level <= {$_POST['levelmax']}"; $id_clause=($_POST['id']) ? " AND userid LIKE('%{$_POST['id']}%')" : ""; $name_clause=($_POST['name']) ? " AND username LIKE('%{$_POST['name']}%')" : ""; $location_clause=($_POST['location']) ? " AND location LIKE('{$_POST['location']}')" : ""; $online_clause=($_POST['online']) ? " AND laston >= unix_timestamp()" : ""; $daysmin_clause=($_POST['daysmin']) ? " AND daysold >= {$_POST['daysmin']}" : ""; $daysmax_clause=($_POST['daysmax']) ? " AND daysold <= {$_POST['daysmax']}" : ""; $moneymin_clause=($_POST['moneymin']) ? " AND money > {$_POST['moneymin']}" : ""; $q=$db->query("SELECT * FROM users $levelmin_clause$levelmax_clause$id_clause$name_cl ause$location_clause$online_clause$daysmin_clause$ daysmax_clause$moneymin_clause",$c); print " <table width='75%' cellspacing='1' class='table'><tr><th><h3>Prisoner <span class='highlight'>Search</span> Results</h2></th></tr></table>"; print"<table width='75%'><tr><td colspan='5'>";print mysql_num_rows($q)." Users found. </td></tr><tr colspan=1 class='table'><th>User</th><th>Level</th><th>Money</th><th>Mug</th><th>Attack</th></tr>"; while($r=mysql_fetch_array($q)) { print "<tr><td><a href='viewuser.php?u={$r['userid']}'>"; print" {$r['username']}"; print"</a></td><td>{$r['level']}</td><td>\${$r['money']}</td><td><a href="http://mug.php?ID={$r[" target="_blank">[Mug]</a></td><td><a href="http://attack.php?ID={$r[" target="_blank">[Attack]</a></td></tr>"; } print "</table>"; $sql = sprintf("SELECT * FROM <span class='highlight'>search</span> WHERE userid = %d ", $ir['userid']); $q1 = mysql_query($sql); if(mysql_num_rows($q1) > 0) { $updatesearch = sprintf ( "UPDATE `search` SET `id` = '%s', `moneymin` = '%d', `daysmax` = '%s', `daysmin` = '%s', `levelmin` = '%d', `levelmax` = '%d', `location` = '%d', name = '%s', `online` = '%s' WHERE `userid` = ('%u')", $_POST['id'], $_POST['moneymin'], $_POST['daysmax'], $_POST['daysmin'] , $_POST['levelmin'], $_POST['levelmax'], $_POST['location'], $_POST['name'], $_POST['online'], $ir['userid'] ); $db->query($updatesearch); } else { $insertsearch = sprintf ( "INSERT INTO `search` values ('' , '%u' , '%u' , '%s' , '%s' , '%u' , '%u' , '%s' , '%u' , '%s', '%s' )", $ir['userid'], $_POST['moneymin'], $_POST['daysmax'], $_POST['daysmin'] , $_POST['levelmin'], $_POST['levelmax'], $_POST['id'], $_POST['location'], $_POST['name'], $_POST['online'] ); $db->query($insertsearch); } } else if($_POST['clear']) { $sql = sprintf("SELECT * FROM <span class='highlight'>search</span> WHERE userid = %d ", $ir['userid']); $q1 = mysql_query($sql); if(mysql_num_rows($q1) > 0) { $deletesearch = sprintf ( "DELETE FROM `search` WHERE `userid` = ('%u')", $ir['userid'] ); $db->query($deletesearch); print"last <span class='highlight'>Search</span> has been Deleted"; } else { print"You have no searches saved to delete... Stupid!!"; } } ?> im getting this error Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/getty/public_html/searchdo.php on line 56 line 56 print"</a></td><td>{$r['level']}</td><td>\${$r['money']}</td><td><a href='mug.php?ID={$r['>[Mug]</a></td><td><a href='attack.php?ID={$r['>[Attack]</a></td></tr>"; any help would be great Quote Link to comment Share on other sites More sharing options...
prototype Posted February 1, 2012 Share Posted February 1, 2012 (edited) peace of cake find print"</a></td><td>{$r['level']}</td><td>\${$r['money']}</td><td><a href='mug.php?ID={$r['>[Mug]</a></td><td><a href='attack.php?ID={$r['>[Attack]</a></td></tr>"; and replace with print"</a></td><td>{$r['level']}</td><td>\${$r['money']}</td><td><a href='mug.php?ID={$r['userid']}'>[Mug]</a></td><td><a href='attack.php?ID={$r['userid']}'>[Attack]</a></td></tr>"; hope it works Edited February 1, 2012 by prototype Quote Link to comment Share on other sites More sharing options...
Spudinski Posted February 1, 2012 Share Posted February 1, 2012 (edited) Why is your script so convoluted? There's no need to apply a filter to every variable individually, you can use a loop. Replace line 56 with: print '</a></td> <td>' . $r['level'] . '</td> <td>' . $r['money'] . '</td> <td><a href="mug.php?ID=' . $r['userid'] . '">[Mug]</a></td> <td><a href="attack.php?ID= ' .$r['userid'] . '">[Attack]</a></td> </tr>'; Edited February 1, 2012 by Spudinski pfft... typo Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 1, 2012 Author Share Posted February 1, 2012 its not my script i got it off here but last comment was in 2010 and when i tried to reply there it wouldnt let me so i posted it here ok spudinski your way gives me this error Parse error: syntax error, unexpected T_STRING in /home/getty/public_html/searchdo.php on line 57 <td> . $r['level'] . '</td> and prototype thanks :) worked fine just got a error with the stupid sql file now :( Quote Link to comment Share on other sites More sharing options...
Spudinski Posted February 1, 2012 Share Posted February 1, 2012 Pfft, type. Edited. Post the error you get from the "sql" file. Quote Link to comment Share on other sites More sharing options...
Uridium Posted February 1, 2012 Share Posted February 1, 2012 on line 3 of spudinskis code if you want the money too show correctly just overwrite that line with <td>' .money_formatter($r['money']) . '</td> Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 1, 2012 Author Share Posted February 1, 2012 (edited) QUERY ERROR: Query was SELECT * FROM users WHERE level >= 1 AND level <= 500 ause AND location LIKE('1')$ daysmax_clause AND money > 1000 i got the mod from here but i couldnt reply there for some reason http://makewebgames.io/showthread.php/33382-New-member-search?highlight=search in the sql bit it doesnt say anything like ALTER TABLE users ADD etc Edited February 1, 2012 by Newbie posted wrong link fixed now Quote Link to comment Share on other sites More sharing options...
Uridium Posted February 1, 2012 Share Posted February 1, 2012 whats "ause" mean ? is that supposed to be something else Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 1, 2012 Author Share Posted February 1, 2012 i dunno illusions when i go onto my search.php everything works fine when i try to search say anyone with 1000 or more in london and hit search i get that error people on the other post said they added it to there game and it worked fine but that was like 2010 Quote Link to comment Share on other sites More sharing options...
Djkanna Posted February 1, 2012 Share Posted February 1, 2012 The code highlighter is bugging up again, notice the variables within the query, $somcl ause ;) Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 1, 2012 Author Share Posted February 1, 2012 (edited) The code highlighter is bugging up again, notice the variables within the query, $somcl ause ;) alright after your comment i was confused so i went back and checked my searchdo.php and found what your talking about (well atleast i think i have) $q=$db->query("SELECT * FROM users $levelmin_clause$levelmax_clause$id_clause$name_clause$location_clause$online_cl ause$daysmin_clause$ daysmax_clause$moneymin_clause",$c); i changed to $q=$db->query("SELECT * FROM users $levelmin_clause$levelmax_clause$id_clause$name_clause$location_clause$online_clause$daysmin_clause$ daysmax_clause$moneymin_clause",$c); now i get this error lol QUERY ERROR: Query was SELECT * FROM users WHERE level >= 1 AND level <= 500 AND location LIKE('1') AND daysold >= 1$ daysmax_clause AND money > 50 that was me searching for users with 1 days or older and $50 or more Edited February 1, 2012 by Newbie Quote Link to comment Share on other sites More sharing options...
Spudinski Posted February 1, 2012 Share Posted February 1, 2012 $q=$db->query("SELECT * FROM users $levelmin_clause$levelmax_clause$id_clause$name_cl ause$location_clause$online_clause$daysmin_clause$daysmax_clause$moneymin_clause",$c); Whitespace she be a bitch. I'd suggest rewriting the script, especially if that's how the query looks. Quote Link to comment Share on other sites More sharing options...
Uridium Posted February 1, 2012 Share Posted February 1, 2012 damn thats some weird **** coding Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 1, 2012 Author Share Posted February 1, 2012 i wish i could lol wouldt have a clue where to start ill just see if i can find a better one and try to add to it Quote Link to comment Share on other sites More sharing options...
Spudinski Posted February 1, 2012 Share Posted February 1, 2012 php.net ~tooshort~ Quote Link to comment Share on other sites More sharing options...
gamble Posted February 1, 2012 Share Posted February 1, 2012 I hate mccodes too much work lol a lot of stuff to change Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.