Jump to content

URL variable problem


flashx

Recommended Posts

Hi guys,

 

I have a bit of a problem,

 

Im using php and mysql and have succeded in storing variables inside of a URL:


echo "<a href='report.php?id=$varmemberid&colour=$varcolour'>test</a> ";

 

i retrieve varmemberid and colour from the mysql database:


$tbl_name = "members";

			mysql_select_db($db_name) or die (mysql_error());

			$query="SELECT * FROM $db_name ORDER BY  `members`.`the_members` ASC";
			$result=mysql_query($query);


			$num=mysql_numrows($result);

			$i=0;
			while ($i < $num) {
			$varmemberid=mysql_result($result,$i,"member_id");	
			$varcolour=mysql_result($result,$i,"colour");

 

that works all fine and dandy for numbers eg: "123" however if i go to insert a member id of "123t" i get this error:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 12 in /home/flashx/public_html/login/report-header.php on line 47

 

im guessing it has something to do with the 'int' in this line:

$memberid = (int) $_GET['memberid'];

 

how do i fix this?

 

Cheers

 

Link to comment
https://forums.phpfreaks.com/topic/221957-url-variable-problem/
Share on other sites

I'm wondering why the int value was placed there to begin with, I'm guessing the mysql table can allow letters and not just set as int, because you are trying to use a member id that also contains a letter.

 

Well the int value was meant to be there as some sort of security measure that was just a number and not anything else in the get value, so instead try using this.

 

$memberid = mysql_real_escape_string($_GET['memberid']);

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.