Missing data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
imatrox05
Forum Newbie
Posts: 16
Joined: Wed Mar 29, 2006 8:44 pm

Missing data

Post by imatrox05 »

Code: Select all

$sql = "SELECT * FROM `qcheck` WHERE  jobno = $jid";
$result2 = mysql_query ($sql) or die ("Query failed");
while ($row = mysql_fetch_array ($result2)) {
		echo '<tr>';
        echo '<td>'. $row[1] .'</td>';
        echo '<td>'. $row[2] .'</td>';
        echo '<td>'. $row[3] .'</td>';
        echo '<td><a href = chapw_report.php?chap='.$row2[0].'&pid='.$row[4].'>'. $row2[0] .'</a></td>';		
									
		
	}
}
in the chapw_report.php page i get the sent data thru
$cid = $HTTP_GET_VARS['chap'];
$pid = $HTTP_GET_VARS['pid']; and then proceed with my reports.

Now for example if $row[0] returns something like "Spindle" then the data passed thru url is like this

chapw_report.php?chap=spindle&pid=12421

so i dont have any problems with processing BUT if my $row[4] returns something like "Master Cylinder" then the whole keyword is not sent and the url looks like this

chapw_report.php?chap=master

How can i overcome this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. always use quotes around attribute values
  2. rawurlencode() may be of interest
imatrox05
Forum Newbie
Posts: 16
Joined: Wed Mar 29, 2006 8:44 pm

Post by imatrox05 »

feyd wrote:
  1. always use quotes around attribute values
i tried that but even then the result was
*.php?chap="Master
imatrox05
Forum Newbie
Posts: 16
Joined: Wed Mar 29, 2006 8:44 pm

Post by imatrox05 »

Thanks guys!

I solved the issue using this

echo '<td><a href = chapw_report.php?chap='.str_replace(' ','%20',$row2[0]).'&pid='.$row[4].'>'. $row2[0] .'</a></td>';
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

imatrox05 wrote:Thanks guys!

I solved the issue using this

echo '<td><a href = chapw_report.php?chap='.str_replace(' ','%20',$row2[0]).'&pid='.$row[4].'>'. $row2[0] .'</a></td>';
Why not just use rawurlencode()

Code: Select all

echo '<td><a href = chapw_report.php?chap='.rawurlencode($row2[0]).'&pid='.$row[4].'>'. $row2[0] .'</a></td>';
much better and versatile
imatrox05
Forum Newbie
Posts: 16
Joined: Wed Mar 29, 2006 8:44 pm

Post by imatrox05 »

@Pimptastic

i'll give that a try too. Thanks a lot
Post Reply