-
Posts
422 -
Joined
-
Last visited
-
Days Won
1
Everything posted by awjudd
-
The original query should still hold given your table structure. With just changing the field I called slot to SlotID. What was it about the select after the union that threw you for a loop? ~judda
-
Your quotes for the surname are incorrect: From: $gmapSql2 .= " AND Surname = ''{$surname}"; To: $gmapSql2 .= " AND Surname = '{$surname}'"; I also noticed that the $langSpoken thing will also have a problem because your if statement is missing curly braces. i.e. From: if($langSpoken !="All Languages") $gmapSql2 .= " WHERE LanguageSpoken ='{$langSpoken}' OR LanguageSpoken2 ='{$langSpoken}' OR LanguageSpoken3 ='{$langSpoken}'"; $gmapSql2 .= " OR LanguageSpoken4 ='{$langSpoken}' OR LanguageSpoken5 ='{$langSpoken}'"; To: if($langSpoken !="All Languages") { $gmapSql2 .= " WHERE LanguageSpoken ='{$langSpoken}' OR LanguageSpoken2 ='{$langSpoken}' OR LanguageSpoken3 ='{$langSpoken}'"; $gmapSql2 .= " OR LanguageSpoken4 ='{$langSpoken}' OR LanguageSpoken5 ='{$langSpoken}'"; } This should make the query valid. ~judda
-
What part of the query are you confused about? If you post your table structure, then I may be able to make it more tuned to your actual table rather than my guessimation as to what the table may be ... ~judda
-
The actual query really depends on your implementation ... however, something like this may work: SELECT slot AS SlotRank, slot FROM slots WHERE slot > :current_slot ORDER BY slot UNION SELECT slot + 8 AS SlotRank, slot FROM slots WHERE slot <= :current_slot ORDER BY slot Where :current_slot is the current slot that you are in. First query: Grab anything that is after our current slot Second query: Grab anything that is less than or is our current slot offsetting it by the maximum number of elements in your group (i.e. so that they have higher slot numbers. That make sense? ~judda
-
I believe that the syntax error you just provided us with is because you are missing the comma between losses and SUM ... i.e. SELECT *, case when (kills = 0) then 0 when (deaths = 0) then 1000 else ((kills*1.0)/(deaths*1.0)) end as killdeathratio, ($scoreFormula) as totalscore FROM ( SELECT gp.name as name, bans.name as banname, avg(dp.courierkills) as courierkills, avg(dp.raxkills) as raxkills, avg(dp.towerkills) as towerkills, avg(dp.assists) as assists, avg(dp.creepdenies) as creepdenies, avg(dp.creepkills) as creepkills, avg(dp.neutralkills) as neutralkills, avg(dp.deaths) as deaths, avg(dp.kills) as kills, COUNT(*) as totgames, case when (kills = 0) then 0 when (deaths = 0) then 1000 else ((kills*1.0)/(deaths*1.0)) end as killdeathratio, SUM(case when(((dg.winner = 1 and dp.newcolour < 6) or (dg.winner = 2 and dp.newcolour > 6)) AND gp.`left`/ga.duration >= $minPlayedRatio) then 1 else 0 end) as wins, SUM(case when(((dg.winner = 2 and dp.newcolour < 6) or (dg.winner = 1 and dp.newcolour > 6)) AND gp.`left`/ga.duration >= $minPlayedRatio) then 1 else 0 end) as losses , SUM(case when( (gp.`leftreason` LIKE ('%ECONNRESET%')) OR (gp.`leftreason` LIKE ('%was dropped%')) ) then 'DISC' ) as disc FROM gameplayers as gp LEFT JOIN dotagames as dg ON gp.gameid = dg.gameid LEFT JOIN dotaplayers as dp ON dg.gameid = dp.gameid AND gp.colour = dp.colour AND dp.newcolour <> 12 AND dp.newcolour <> 6 LEFT JOIN games as ga ON dp.gameid = ga.id LEFT JOIN bans on bans.name = gp.name WHERE dg.winner <> 0 $_sql GROUP BY gp.name having totgames >= $games) as i ORDER BY $order $sortdb, name $sortdb LIMIT $offset, $rowsperpage
-
How to check if an email entered is a valid Paypal email account.
awjudd replied to theITvideos's topic in PHP Coding Help
You may be able to use IPN to help you with that. This site: https://www.paypaltech.com/sg2/ generates scripts for you which can be run (automatically) after a purchase has been made. -
Assuming it just associated with a button ... you could do something like this ... <script type = 'text/javascript'> function checkDelete ( id ) { if ( confirm ( "Are you sure you want to delete " + id + "?" ) ) { // relocate to another page document.location.href = 'deleteurl.php?id=' + id; } else { alert ( "Stop the presses!" ); } } </script> Then in your actual page you would have something like: <input type = 'button' onclick = 'checkDelete("<?php echo $id; ?>")' /> ~juddster
-
You can't forget Perfect Dark ... or Donkey Kong 64 ... though I was more of a Goldeneye guy myself ... ~juddster
-
We don't bite (for the most part) ~juddster
-
Without any knowledge of your form ... my guess is that it actually is just getting a string for $_POST [ 'author' ] and not an array ... ~juddster
-
Firstly ... you gotta give it more than 50 minutes before bumping ... that is just rude. What are you expecting within the quotes? Letters? Numbers? etc ... /\{display="([A-Z_]*)"\}/i Should give you what you want based on the sample. http://rubular.com/r/rk7rKB7jRo ~juddster
-
Compare a single value column against multiple possible values
awjudd replied to Errant_Shadow's topic in MySQL Help
Have you tried to use the 'BETWEEN' operator? http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between Basically you want everything that isn't between a set of numbers? ~juddster -
SELECT 1 FROM table WHERE id = 2 That should work ... it just sets an arbitrary value that it will automatically grab ~juddster
-
== is NOT an assignment. Therefore if you are trying to assign the value you are going about it the wrong way ... especially since it is in an if statement ... ~juddster
-
Another thing is, in query you have $keyword whereas whenever you reference it outside of the query it is $search_term (and you never assign $search_term to $keyword). So the query won't ever return what you want it to Single row expected: $arr = mysql_fetch_array ( $query ); print_r ( $arr ); // Display all information returned echo $arr [ 'Note_ID' ]; // Echo only the 'Note_ID' which is returned Multiple rows returned: while ( $arr = mysql_fetch_array ( $query ) ) { print_r ( $arr ); // Display all information returned echo $arr [ 'Note_ID' ]; // Echo only the 'Note_ID' which is returned } Hope this helps. ~juddster
-
It is suppressing any errors which may occur / be thrown while in the function. http://php.net/manual/en/language.operators.errorcontrol.php ~juddster
-
I'm guessing it has to do with your single quotes. They look to be a different character ... but that could just be the font ... ~juddster
-
If the selection returns a value from a select box or something similar, if you just send back an id and then map those ids to a particular value to add to your query, you should be safe. Or as Brian said ... use parameters. $query = 'SELECT * FROM `details` '; switch ( $listoption ) { case 1: $query .= 'WHERE otype = \'bugger\' '; break; case 2: $query .= 'WHERE otype = \'booger\' '; break; default: /* Do nothing (ALL) */ } /* Execute $query */ ~juddster
-
How about something like this? $arr = array ( 'contactusform' => array ( 'field1' => array ( 'fieldid' => 'nameField', 'fieldtext' => 'Name' ), 'field2' => array ( 'fieldid' => 'nextField', 'fieldtext' => 'stuff here' ) ); ~juddster
-
You never actually run the first query against the database ... <?php session_start(); include('../database.php'); $userid = $_SESSION['user']; $userxp = mysql_fetch_array ( mysql_query ( "SELECT xp FROM user WHERE username = '$userid'" ) ); $amount = 19999999; if ($userxp [ 'xp' ] > $amount){ $query = "UPDATE `user` SET `xp`=(`xp`-20000000) WHERE `username` = '$userid' LIMIT 1"; $result = mysql_query($query) or die('Query: ' . $query . '<br />Failed with: ' . mysql_error()); echo "You have purchased this item"; } else { echo "You do not have enough xp!"; } ?> Would be a hacked out version of your code so that it should work. ~juddster
-
In your where clause, SQL doesn't know where to look (which table to look in) at the 'name' field because it is in both. You will have to tell it to use either the avatar or the members table specifically. ~juddster
-
I guess it depends on the DBMS because I know that for SQL server it does actually make a difference ... as for mySQL you may be right ... I've never tried. ~juddster
-
I'm guessing for each of the tables there is at least 1 field within each of the rows which are different. Thus making the DISTINCT catch it as a unique value. You will probably have to reduce the returned set (from * to something else) in order to remove the duplication. Another thing I noticed is you are using a cross join between tbl1 and tbl2 (,) and then restricting it. This may affect the speed of your query. You may want to change it to something like this: $sql = "SELECT DISTINCT tbl1.*, tbl2.* FROM tbl1 a JOIN tbl2 b ON ( a.site1ID = b.siteID OR a.site2ID = b.siteID ) WHERE tbl1.active='0' AND tbl2.userID='".$me['id']."' ORDER BY b.success DESC LIMIT 10"; to work better. It won't fix your DISTINCT problem, but it may speed things up a bit ... You'll need to identify the key fields before you can get the DISTINCT to work as you wanted it to. ~juddster
-
That is awesome ... but yeah ... it does pretty much nothing ... but ... All your base belong to us! ~juddster
-
Why are these split into two queries? You could easily do it all in one I believe. ~juddster