Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
12-07-2011, 06:54 AM #1
- Join Date
- Feb 2010
- Thanked 0 Times in 0 Posts
Using _GET function to grab SQL query string
Sorry for creating a new thread but I'm trying to target the exact source of the problem I am having and each time, a new question comes up that I need to ask.
I have 2 sites: MMOCraze.com and RPGMax.com.
The error is occurring on RPGMax.com.
The error occurs on the page http://www.rpgmax.com/mmo/gamedirectory/gameprofile
MMOCraze has the same page but slightly different URL structure: http://www.mmocraze.com/game-directory/game-profile.
The game directory pages on both sites use the same template files with different databases. The information and structure in both databases are the same. On the game directory page for both sites, a loop is created to output a list of games stored in the database table. Each game in the list has a link that directs the user to the game's profile page.
The code to create that link is as follows:
<a href=http://www.rpgmax.com/mmo/gamedirectory/gameprofile/?gameId=" . $row['gameId'] . ">" . $row['gameName'] . "</a>
<a href=http://www.mmocraze.com/game-directory/game-profile/?gameId=" . $row['gameId'] . ">" . $row['gameName'] . "</a>
$gameId = $_GET['gameId'];
$result = mysql_query("SELECT * FROM wp_rpgmax_games WHERE gameId=$gameId");
$row = mysql_fetch_array($result);
<h1>Official Site: <a href=" . $row['gameUrl'] . " target=_new>" . $row['gameName'] . "</a></h1>
<img src=" . $row['gameLogoUrl'] . " alt='Game Logo' border='0' height=105></td>
Any ideas? That's the main problem...MMOCraze works but NOT RPGMax. MMOcraze returns an array but not RPGMax, which is weird because they use the same htaccess and same sql/php code.
12-07-2011, 07:00 AM #2
Well, neither one of the URLs are the actual URLs of the pages that are doing the SQL.
Normally, you'd expect to see something likeCode:
(1) In both cases, those are just directories and you are then hitting the *default* page in the directory. Something like "default.php" or "index.php".
(2) You are using URL rewriting in Linux, and indeed the actual page maybe is something like
So...which is it? default page or url rewrites?Be yourself. No one else is as qualified.
12-07-2011, 07:06 AM #3
Hmmmm...I hit this page thus:
Whereas if I hit *this* page
http://www.mmocraze.com/game-directory/game-profile/?gameId?989Be yourself. No one else is as qualified.
12-07-2011, 07:09 AM #4
If you know what the *actual* URL is, the one that that URL rewrite is taking us to, try using it directly and I'll bet it works.Be yourself. No one else is as qualified.
12-07-2011, 07:30 AM #5
- Join Date
- Feb 2010
- Thanked 0 Times in 0 Posts
How would I get the actual url?
Both sites have the same htaccess files in their root files.
Their wordpress permalink settings have custom structure seo settings:
MMOCraze uses --> /%post_id%/%category%/%postname%/
RPGMax uses --> /%category%/%postname%/
Both sites use the game profile page as the target page but the code uses an sql query string to attach the gameId to the URL, hence the /?gameId=XXX where XXX is the gameID variable which gets replaced by the corresponding gameId in the database. _GET, I believe is a function that "gets" info from the inputting page and adds the info "inputted" into the browser url. I believe that input forms add "/?" to the browser URL when submitting info that has a target page using _GET. The sql string forces the ?/ into the URL and the _GET function on the target game profile page "gets" the gameId from the sql query and attaches it to the URL. That's how it should work...thats how MMOCraze works, I believe.
By the way, I tried the URL you had on my firefox browser (latest version), http://www.mmocraze.com/game-directo...le/?gameId=989, and the server didn't change the URL for me...stayed the same.
Last edited by crazykid; 12-07-2011 at 07:36 AM.
12-07-2011, 08:05 AM #6
$_GET["name"] looks in the query string (the part of the URL after the question mark) and tries to find name=value and, if found, returns the value.
So if you have a URL ending in "?gameID=17" that means the $_GET looks for "gameID=" and, when found, returns "17" (as a string, by the way, as all such values are strings).
To pass multiple name=value pairs in a query string you separate them with an ampersand.
So, for example "xyz.php?gameId=17&name=John" would allow your PHP code to doCode:
$id = $_GET["gameId"]; $user = $_GET["name"];Code:
$framitzammerzappen = $_GET["gemeId"]; $zyai188_8818BBcx = $_GET["name"];
$_GET["name"]it will get a null value. You can test that in PHP using
SO...if your htaccess has a bug so that it rewrites the URL with passing along the stuff from the question mark onward, PHP will never be able to use $_GET. Simple as that.
I don't use Linux (did many years ago) and it would take me a while to figure out your htaccess settings, so I'd suggest that if you don't know how to fix them you find some Linux guru who does.Be yourself. No one else is as qualified.
12-07-2011, 08:06 AM #7
Oh, and I think I typoed on that one where I thought it changed ?gameID=989 to ?gameID?989
I tried it again with ?gameId=1 and it worked just fine.
But the URL that removed the ? completely continues to do so.Be yourself. No one else is as qualified.
12-07-2011, 08:08 AM #8the code uses an sql query string to attach the gameId to the URL,Be yourself. No one else is as qualified.