Jump to content

X--Solved--XHelp !! $_GET error


ludjer

Recommended Posts

OK here is my problem
i type in a "file.php"
and it does the loo of the sql database
but now when use this "file.php?newsid=11"
a blank screen comes up
i want it to echo $newsid but it wont
it will echo amount but no id
if any1 can help me i would really be happy

heres my code
[code]<?php
require_once('config/database.php');
$amount = '5';
if (isset ($_GET['newsid']))
{
$_GET['newsid']= $newsid;
$newsid= $_GET['newsid'];
echo $newsid;
echo $amount;

}
else {
$amount = '5';
$result = mysql_query("SELECT * FROM news LIMIT $amount");

while ( $row = mysql_fetch_array($result) )
{?>

<div style="width:450px;">

<h3><u><?php echo @$row['title']; ?></a></u></h3>
<p><?php echo nl2br(@$row['content']); ?></p>
<p><b>Posted On:</b><i><?php echo @$row['date']; ?> by <?php echo @$row['user']; ?></i></p><br />
<hr />

</div>
<?php
}
}?>[/code]

thx
ludger
Link to comment
https://forums.phpfreaks.com/topic/20248-x-solved-xhelp-_get-error/
Share on other sites

lol ^ you beat me to it.


Also, you should validate the newsid or at least use something like this.

[code=php:0]
$newsid = mysql_real_escape_string(trim($_GET['newsid']));
[/code]

And maybe use a preg_match to make sure that it is has nothing but numbers in it. Otherwise you may find your site getting cracked


Good Luck,
Tom
i dont get it

here is my new code
and its still not getting newsid
still the same problem
[code]<?php
require_once('config/database.php');
$amount = '5';
if (isset ($_GET['newsid']))
{
$_GET['newsid']= $newsid;
$newsid = mysql_real_escape_string(trim($_GET['newsid']));
echo $newsid;
echo $amount;

}
else {
$amount = '5';
$result = mysql_query("SELECT * FROM news LIMIT $amount");

while ( $row = mysql_fetch_array($result) )
{?>

<div style="width:450px;">

<h3><u><?php echo @$row['title']; ?></a></u></h3>
<p><?php echo nl2br(@$row['content']); ?></p>
<p><b>Posted On:</b><i><?php echo @$row['date']; ?> by <?php echo @$row['user']; ?></i></p><br />
<hr />

</div>
<?php
}
}?>[/code]

Archived

This topic is now archived and is closed to further replies.

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