Jump to content

Recommended Posts

Hi,

 

I'm in a bit of a sticky situation. Y'See, I have made a page construct a link that looks a little bit like this:

 

http://www.runescapez.com/itempage.php?itemid=00007

 

And I want to make a page that then uses the $_GET method to run a mysql_query.

 

This part of the code that is relevant:

 

<?php
$result = mysql_query("SELECT * FROM items WHERE itemid = '$_GET["itemid"]'");
$row = mysql_fetch_array($result)
?>

 

OR

 

<?php
$getid = $_GET["itemid"]
$result = mysql_query("SELECT * FROM items WHERE itemid = '$getid'");
$row = mysql_fetch_array($result)
?>

 

When I try to view the page, it comes up with this error:

 

Parse error: syntax error, unexpected T_VARIABLE in ~hidden~ on line 19

 

How else could I extract the 'itemid' from the url (itempage.php?itemid=#here) and then use that to run a mysql_query to get all the matching fields where itemid= the get results?

 

The reason I want this data is to show a page that shows bits of 1 set of data using something like this:

 

Examine: <?php echo $row['examine'] ?>

- examine is a field in the table.

 

How could I do this?

 

Thanks in advance,

Malev.

Your getting the error from this line

$row = mysql_fetch_array($result)

 

Your missing the semi-colon at the end.

 

Also, make sure your sanitizing the input from the URL before you use it in your query.

well, i just had a quick glance but that sort of error message usually means that you are just missing something simple in your code.

 

An example is like leaving a semicolon ; off the end of a line.

 

I'm fairly new at this myself but try this as your select statement...

 

"SELECT * FROM items WHERE itemid ='".$_GET['itemid']."'"

 

good luck.

 

Also, remember to 'sanitize' your $_GET data before using it in a mysql query...

Right, is that because you need to POST the itemname so that say a Search Engine comes along and tries to 'Spider' the page, it'll do it properly?

 

Because the url remains the same with that 'sanitize' script, ultimately making no difference for 'Malevolent' people... *Good use of Malevolent behicthebuilder*.

 

I'll set this post to 'Solved' when I find out about sanitization. :P

Right, is that because you need to POST the itemname so that say a Search Engine comes along and tries to 'Spider' the page, it'll do it properly?

 

no we use POST to post varables/info to the correct varable set so it get's there.....

 

 

sanitization

 

used for information posted to the database.....

 

update or insert

 

addslashes();

mysql_real_escape_string();

 

common ones above.......

 

 

$_GET[''] get the info in a url as you no,

but it always usefull to set a condition for the get

so people dont spam ur database.....

 

spiders/bots dont like php they only use html/css

 

good luck........

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.