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
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']);

Link to comment
Share on other sites

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.