Forum Moderators: coopster

Message Too Old, No Replies

What i am doing wrong

         

bodycount

4:04 pm on May 8, 2006 (gmt 0)

10+ Year Member



I used this script on php4 and i works but i can't get it to work with php5, but it could be just me.

I think i could be the way i have done this but not to sure.

<a href=\"returnnote.php?row_ID=$id\">

this should send the row id to returnnote.php so that it can get it out of the data base, it seems to get the right id. See below

"http://localhost/returnnote.php?row_ID=5"
--------------------------------------------------------

<?php

include ("connection.php");

$RMA = $_POST['RMA'];
$id = $_POST['id'];
$row_ID = $_POST['row_ID'];

if(isset($_GET['RMA']) && $_GET['RMA']) $RMA = $_GET['RMA'];

else $RMA = 1;

//$query = "SELECT * FROM `rmatable` WHERE RMA = '$RMA' LIMIT 200";

$query15 = "SELECT * FROM rmatable WHERE RMA LIKE \"%$RMA%\" LIMIT 200";
$result15 = mysql_query($query15);
if($num=mysql_numrows($result15))
{
echo "<center>";
echo "<table style= width: 100%; >";
echo "<tr><td colspan=2 ><b>Results For $RMA</td></tr>";
echo "<td></table>";
echo "</center>";
while ($record = mysql_fetch_array($result15))
{

$id = $record["id"];
$RMA = $record["RMA"];
$CUSTOMER = $record["CUSTOMER"];
$MODULE = $record["MODULE"];
$SERIALNO = $record["SERIALNO"];
$WARR = $record["WARR"];

echo "<center>";
echo "<table style='width: 1000px; height: 52px;' border='3'>";
echo "<tr><td style='width: 245px; text-align: center;' nowrap><font size=-1 ><b>Comtech Module</td><td style='width: 82px; text-align: center;' nowrap><font size=-1 ><b>Serial No.</td><td style='width: 206px; text-align: center;'><font size=-1 ><b>Customer</td><td style='width: 90px; text-align: center;' nowrap><font size=-1 ><b>In Warranty</td><td style='width: 106px; text-align: center;' nowrap><font size=-1 ><b>Returns Note</td><td style='width: 100px; text-align: center;' nowrap><font size=-1 ><b>Warranty Note</td></tr>";
echo "<td style='width: 245px; text-align: center;' nowrap><font size=-1>$MODULE</td>";
echo "<td style='width: 82px; text-align: center;' nowrap><font size=-1>$SERIALNO</td>";
echo "<td style='width: 206px; text-align: center;' nowrap><font size=-1>$CUSTOMER</td>";
echo "<td style='width: 90px; text-align: center;' nowrap><font size=-1>$WARR</td>";
echo "<td style='width: 106px; text-align: center;' nowrap><a href=\"returnnote.php?row_ID=$id\"><font size=-1>Returns Note</a></td>";
echo "<td style='width: 100px; text-align: center;'><a href=\"warrantynote.php?row_ID=$id\"><font size=-1>Warranty Note</a></td></tr>";
echo "</table>";
echo "</center>";
}
}
?>

---------------------------------------------------------

---------------------------------------------------------

returnnote.php SCRIPT

---------------------------------------------------------

<?php

include ("connection.php");

$sql = "SELECT * FROM rmatable WHERE id = '$row_ID' LIMIT 0, 30";

$query = mysql_query($sql);

while ($row = mysql_fetch_array($query))
{
$id = $row["id"];
$RMA = $row["RMA"];
$CUSTOMER = $row["CUSTOMER"];
$ADDRESSL1 = $row["ADDRESSL1"];
$ADDRESSL2 = $row["ADDRESSL2"];
$ADDRESSL3 = $row["ADDRESSL3"];
$ADDRESSL4 = $row["ADDRESSL4"];
$POSTCODE = $row["POSTCODE"];
$ADDRESSL5 = $row["ADDRESSL5"];
$CONTACT = $row["CONTACT"];
$RETURNREASON = $row["RETURNREASON"];
$FAULTDESCRIPTION = $row["FAULTDESCRIPTION"];
$MODULE = $row["MODULE"];
$SERIALNO = $row["SERIALNO"];
$FIXACTION = $row["FIXACTION"];
$JOBTIME = $row["JOBTIME"];
$COST = $row["COST"];

echo "<center>";
echo "<table style= width: 100%; >";
echo "<tr><td colspan=2 ><b>Returns Note For $RMA</td></tr>";
echo "<td><table>";
echo "<tr style ='height: 25px;'><td align=left><font size=-1 ><b>RMA Number :</td><td><font size=-1>$RMA</td></tr>";
echo "<tr valign=top style ='height: 35px;'><td align=left><font size=-1 ><b>Customer Name :</td><td><font size=-1>$CUSTOMER</td></tr>";
echo "<tr style ='height: 15px;'><td align=left><font size=-1 ><b>Address :</td><td><font size=-1>$ADDRESSL1</td></tr>";
echo "<tr style ='height: 15px;'><td align=left><font size=-1 ><b>Address :</tb><td><font size=-1>$ADDRESSL2</td></tr>";
echo "<tr style ='height: 15px;'><td align=left><font size=-1 ><b>Town :</td><td><font size=-1>$ADDRESSL3</td></tr>";
echo "<tr style ='height: 15px;'><td align=left><font size=-1 ><b>County :</th><td><font size=-1>$ADDRESSL4</td></tr>";
echo "<tr style ='height: 15px;'><td align=left><font size=-1 ><b>Postcode :</th><td><font size=-1>$POSTCODE</td></tr>";
echo "<tr valign=top style ='height: 35px;'><td align=left><font size=-1 ><b>Country :</th><td><font size=-1>$ADDRESSL5</td></tr>";
echo "<tr style ='height: 25px;'><td align=left><font size=-1 ><b>Contact Name :</th><td><font size=-1>$CONTACT</td></tr>";
echo "<tr style ='height: 25px;'><td align=left><font size=-1 ><b>Comtech Module :</th><td><font size=-1>$MODULE</td>";
echo "<td align=left><font size=-1 ><b>Serial Number :</th><td><font size=-1>$SERIALNO</td></tr>";
echo "<tr style ='height: 25px;'><td align=left><font size=-1 ><b>Reason for Return :</th><td><font size=-1>$RETURNREASON</td></tr>";
echo "<tr><td align=left valign=top style ='height: 100px;'><font size=-1 ><b>Fault Discription :</th><td valign=top><font size=-1>$FAULTDESCRIPTION</td></tr>";
echo "<tr><td align=left valign=top style ='height: 100px;'><font size=-1 ><b>Rectification/Action :</th><td valign=top style='width: 400px;'><font size=-1>$FIXACTION</td></tr>";
echo "<tr><td align=left><font size=-1 ><b>Job Time :</th><td><font size=-1>$JOBTIME</td>";
echo "<td align=left><font size=-1 ><b>Billable Cost :</th><td><font size=-1>$COST</td></tr>";
echo "</table>";
echo "</center>";
}

?>
---------------------------------------------------------

Any Ideas anyone?

jatar_k

7:53 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



when say "can't get it to work with php5" what exactly is happening?

error messages?
nothing?
is this on the same server?

bodycount

8:38 pm on May 8, 2006 (gmt 0)

10+ Year Member



This page loads

"http://localhost/returnnote.php?row_ID=5"

with the right id but the page is blank,

bodycount

8:40 pm on May 8, 2006 (gmt 0)

10+ Year Member



oh and no it is not on the same server, php4 is on my webserver and the php5 in on my pc.

[edited by: jatar_k at 8:43 pm (utc) on May 8, 2006]
[edit reason] no specific hosts thanks [/edit]

jatar_k

8:44 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you tried turning error reporting up (to 0) and see if there are any errors?

bodycount

9:16 pm on May 8, 2006 (gmt 0)

10+ Year Member



maybe a stupid question but how and where?

jatar_k

9:22 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



at the top of the misbehaving script

[php.net...]

bodycount

9:37 pm on May 8, 2006 (gmt 0)

10+ Year Member



Parse error: parse error, unexpected T_STRING in C:\www\returnnote.php on line 4

line 4 is

int error_reporting ( [1] );

jatar_k

10:45 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



all you need is

error_reporting(0);

on that line

bodycount

10:52 pm on May 8, 2006 (gmt 0)

10+ Year Member



no error reported still a blank page.

jatar_k

10:55 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



add an or die statement to all your queries

something isn't returning any data and the whole thing just dies

that's my guess

eelixduppy

10:59 pm on May 8, 2006 (gmt 0)



you want to use error_reporting(E_ALL); to report all errors and warnings

eelix

bodycount

11:02 pm on May 8, 2006 (gmt 0)

10+ Year Member



returnnote.php i have put the following

$sql = "SELECT * FROM rmatable WHERE id = '$id' LIMIT 0, 30" or die ("no id");

$query = mysql_query($sql) or die ("query");

nothing gets reported back still blank page

jatar_k

11:18 pm on May 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



good point eelixduppy

my fault sorry

eelixduppy

11:23 pm on May 8, 2006 (gmt 0)



The lack of text on your page might be caused because there is a sytax error in your script. One that i've found is that you have
if($num=mysql_numrows($result15))

written when it should be
if($num=mysql_num_rows($result15))

eelix

bodycount

3:07 pm on May 9, 2006 (gmt 0)

10+ Year Member



after changing error_reporting to the following

error_reporting(E_ALL);

I final get an notice w00t.

Notice: Undefined variable: row_ID in C:\www\returnnote.php on line 7.

so how do i define it?

eelixduppy

7:09 pm on May 9, 2006 (gmt 0)



yay

You want to change


$row_ID = $_POST['row_ID'];

To


$row_ID = $_GET['row_ID'];

i don't know why i didn't see that to begin with

Good luck!

eelix

coopster

7:16 pm on May 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



When the variable is in the QUERY STRING like that ...
http://localhost/returnnote.php?row_ID=5

... it is part of a GET request, not a POST. Also, a common practice is to see if the variable does indeed exist before trying to use it, too. You are almost there with your RMA value but try something like this instead, using the ternary operator [php.net]:
$RMA = (isset [php.net]($_GET['RMA'])) ? $_GET['RMA'] : 1; 
$id = (isset [php.net]($_GET['id'])) ? $_GET['id'] : 0;
$row_ID = (isset [php.net]($_GET['row_ID'])) ? $_GET['row_ID'] : '';

I'm not sure why you are using POST and GET, I would expect one or the other here so I just used GET in the example. If the variable is set then we will use it otherwise we can set a default value.

bodycount

9:50 pm on May 9, 2006 (gmt 0)

10+ Year Member



WOW

Thanks guys for all your help, it is working fine now after i change/added

$row_ID = (isset($_GET['row_ID']))? $_GET['row_ID'] : '';

into returnnote.php.

I must say thanks again to all three of you for your help.