Page 1 of 1

Missing data

Posted: Fri Jul 07, 2006 4:00 am
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?

Posted: Fri Jul 07, 2006 4:04 am
by feyd
  1. always use quotes around attribute values
  2. rawurlencode() may be of interest

Posted: Fri Jul 07, 2006 4:19 am
by imatrox05
feyd wrote:
  1. always use quotes around attribute values
i tried that but even then the result was
*.php?chap="Master

Posted: Fri Jul 07, 2006 4:42 am
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>';

Posted: Fri Jul 07, 2006 4:45 am
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

Posted: Fri Jul 07, 2006 5:04 am
by imatrox05
@Pimptastic

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