flashx Posted December 17, 2010 Share Posted December 17, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/221957-url-variable-problem/ Share on other sites More sharing options...
QuickOldCar Posted December 17, 2010 Share Posted December 17, 2010 int in that case is made to convert it to just a number, so I guess if need to have a variable with also letters, must remove the int. $memberid = $_GET['memberid']; Quote Link to comment https://forums.phpfreaks.com/topic/221957-url-variable-problem/#findComment-1148544 Share on other sites More sharing options...
flashx Posted December 17, 2010 Author Share Posted December 17, 2010 oh you rock! thanks for your help, that worked Quote Link to comment https://forums.phpfreaks.com/topic/221957-url-variable-problem/#findComment-1148546 Share on other sites More sharing options...
QuickOldCar Posted December 17, 2010 Share Posted December 17, 2010 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']); Quote Link to comment https://forums.phpfreaks.com/topic/221957-url-variable-problem/#findComment-1148548 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.