...

View Full Version : Php driving me nutz!



mwm
11-15-2006, 03:19 PM
I have php and mysql installed on a windows sbs 2003. I have written an application where it pulls info on customers and the id is passed between pages as additional info on the customer is need by the user. HERE is the problem! The customer info first page (query) works everytime, but when the id is passed to the second page to pull the info (second query) it's blank - no info at all. So, you wait an few seconds and start over and everything works again. I have been able to confirm the problem by running the application directly on the server. What could be wrong? Has this happened to anyone else, where php is slow to respond?

Thanks

UberDragon
11-15-2006, 04:35 PM
How are you passing the id variable to the subsequent pages? Session? Post? Get? Is the variable itself passing but the database query isn't working properly?

Can you show us the query string (the one that works everytime and the one that doesn't)

Need more info :)

~Uber

mwm
11-15-2006, 05:50 PM
Yes, below are the two pages. I echo the id on each page to make sure its being passed. But like I said, id is not always being passed to the second page so the query doesn't work. Thanks for looking at this for me.

<?
session_start();
include "conn.php";
$community=$_POST['community'];
$id= $_POST['id'];
echo $id;
echo "<input type = 'hidden' name = 'id' value = '$id'>";


?>



<html>

<head><link rel=stylesheet type=text/css href=css/default.css>

</head>
<body>

<form action = "custhistory.php" method ="POST">

<h1><p align=center> Corporation</p></h1>
<h3><p align=center>Home Buying Details</p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php">&nbsp;&nbsp;Main </a><a href="contactfirst1.php">&nbsp;&nbsp; Contacts </a>
<a href="custhistory.php">&nbsp;&nbsp; History </a>
</center>

<br>
<hr>

<?



$mysql = "SELECT * from cust where id = '$id' and community= '$community' ";




$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);



$id = $row[0];




$mysql1 = "SELECT date_format(regdate, '%M-%d-%Y'), fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where community= '$community' and id = '$id'";




$result1= mysql_query($mysql1) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Registered</th>";
echo "<th>Guest</th>";
echo "<th></th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";
echo "<th>Phone</th>";
echo "<th>Cell</th>";
echo "<th>Work</th>";
echo "<th>Email</th>";


$j = true;
while ($row = mysql_fetch_row($result1))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>
<?





$mysql2 = "SELECT status, level, adulthousehold,childhousehold,nameage from cust where community= '$community'and id = '$id'";

$result2= mysql_query($mysql2) or die ("Can't connect");







echo "<table border=\"0\">";
echo "<th>Status</th>";
echo "<th>Level</th>";
echo "<th>Adults</th>";
echo "<th>Children</th>";
echo "<th>Names</th>";


$j = true;
while ($row = mysql_fetch_row($result2))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>


<?



$mysql3 = "SELECT realname,realcomp,realadd,realphone from realtor where id = '$id'";




$result3= mysql_query($mysql3) or die ("Can't connect");
echo "<th>&nbsp;Realtor</th>";
echo "<table border=\"0\">";
$j = true;
while ($row = mysql_fetch_row($result3))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result3);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>


<hr>
<?

$query4 = ("SELECT * FROM cust where community = '$community' and id ='$id'");
$result4 = mysql_query($query4);
$row=mysql_fetch_row($result4);


?>


<p align = center></a><?echo $row[3]?> <?echo $row[4]?> is looking for a new home with </center>
<p align = center>2 Bedrooms <input = "checkbox" name ="twobed" value ="<? echo $row[23]?>" size = "1"> 3 Bedrooms <input = "checkbox" name ="threebed" value ="<? echo $row[24]?>" size = "1"> 4 Bedrooms <input = "checkbox" name ="fourbed" value ="<? echo $row[25]?>" size = "1"> 5 or more Bedrooms <input = "checkbox" name ="morebed" value ="<? echo $row[26]?>" size = "1"></p><p align = center> 1.5 Baths <input = "checkbox" name ="onebath" value ="<? echo $row[27]?>" size = "1"> 2 Baths <input = "checkbox" name ="twobaths" value ="<? echo $row[28]?>" size = "1"> 2.5 Baths <input = "checkbox" name ="twohalfbaths" value ="<? echo $row[29]?>" size = "1"> 3 Baths <input = "checkbox" name ="threebaths" value ="<? echo $row[30]?>" size = "1"></p><p align = center> 2 Car Garage <input = "checkbox" name ="twogarage" value ="<? echo $row[31]?>" size = "1"> 2.5 Car Garage <input = "checkbox" name ="twohalfgarage" value ="<? echo $row[32]?>" size = "1"> 3 Car Garage <input = "checkbox" name ="threegarage" value ="<? echo $row[33]?>" size = "1">
<hr>

<p align = center><?echo $row[3]?> presently </center>
<p align = center>Rent <input = "checkbox" name ="rent" value ="<? echo $row[59]?>" size = "1"> Own <input = "checkbox" name ="own" value ="<? echo $row[60]?>" size = "1"> Single Family <input = "checkbox" name ="family" value ="<? echo $row[61]?>" size = "1"> Multifamily <input = "checkbox" name ="multifamily" value ="<? echo $row[62]?>" size = "1"> Live with family <input = "checkbox" name ="livefamily" value ="<? echo $row[63]?>" size = "1">
<hr>
<p align = center>Price Range
<input type ="text" name="price" value = "<?echo $row[64]?>" size = "12"></textarea>
<p align = center>Move Time
<input type ="text" name="movetime" value = "<?echo $row[65]?>" size = "12"></textarea>
<hr>





<p align =center>
<a href="guestmain.php">Main</a></center>
</table>


</form>
</body>
</html>






































































<?
session_start();
include "conn.php";
session_register("id");

echo "<input type = 'hidden' name = 'id' value = '$id'>";
echo $id;

?>




<html>

<head><link rel=stylesheet type=text/css href=css/default.css>

</head>
<body>
<form action = "followupdate.php" method ="POST">
<h1><p align=center>The Corporation</p></h1>
<h3><p align=center>Guest History </p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php">&nbsp;&nbsp;Main </a><a href="contactfirst1.php">&nbsp;&nbsp; Contacts </a>
<?echo $row[11]?><a href="exceptionone.php">&nbsp;&nbsp; Exception Report <a href="contacteditfour.php">&nbsp;&nbsp; Status Change </a><a href="addtouch.php">&nbsp;&nbsp; Add Touch/Note </a><a href="earnestone.php">&nbsp;&nbsp; Earnest </a></center>
<input type = "hidden" name = "tpcount" value = "1">

<br>
<hr>




<?

echo "<input type = 'hidden' name = 'id' value = '$id'>";

$mysql = "SELECT * from cust where id = '$id'";



$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);

$id = $row[0];


$mysql1 = "SELECT fname,lname,address,city,state,zip,hphone,cphone,wphone, email from cust where id = '$id'";







$result1= mysql_query($mysql1) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Guest</th>";
echo "<th></th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";
echo "<th>Phone</th>";
echo "<th>Cell</th>";
echo "<th>Work</th>";
echo "<th>Email</th>";


$j = true;
while ($row = mysql_fetch_row($result1))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";






?>

<?

$mysql2 = "SELECT status,model,elevation,lot from cust where id = '$id'";



$result2= mysql_query($mysql2) or die ("Can't connect");





echo "<table border=\"0\">";
echo "<th>Status</th>";
echo "<th>Model</th>";
echo "<th>Elevation</th>";
echo "<th>Lot</th>";


$j = true;
while ($row = mysql_fetch_row($result2))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>

<hr>
<br>
<?

$mysql4 = "SELECT tpoint, date_format(tpdate, '%M-%d-%Y') from followup where id = '$id' order by tpdate";


$result4= mysql_query($mysql4) or die ("Can't connect");




echo "<table border=\"0\">";
echo "<th>Touch</th>";
echo "<th>Date</th>";


$j = true;
while ($row = mysql_fetch_row($result4))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result4);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>
<hr>
<br>
<?

$mysql6 = "SELECT demo, date_format(demodate, '%M-%d-%Y') from demotbl where id = '$id' order by demodate";


$result6= mysql_query($mysql6) or die ("Can't connect");




echo "<h4>";
echo "<table border=\"0\">";
echo "<th>Demo</th>";
echo "<th>Date</th>";
echo "</h4>";

$j = true;
while ($row = mysql_fetch_row($result6))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result6);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>
<hr>
<br>
<?

$mysql7 = "SELECT date_format(appdate, '%M-%d-%Y') from apptbl where id = '$id' order by appdate";


$result7= mysql_query($mysql7) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Appointments</th>";



$j = true;
while ($row = mysql_fetch_row($result7))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result7);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>

<?
echo "<center>Notes</center>";
$mysql5 = "SELECT * from followup where id = '$id'";

$result5= mysql_query($mysql5) or die ("Can't connect");

$num_results = mysql_num_rows($result5);



for ($i=0;$i<$num_results; $i++)


{



$row = mysql_fetch_array($result5);

echo "<center><table border='0' width='80%'> ";
echo "<tr><th align=left Width =80%></th></tr>";


echo "</td><td align=left>";
echo $row['6'];




echo "</td></tr>";
echo "</table>";



}

if ($num_results==0) echo "No Records";

?>




</form>
</body>
</html>

mlseim
11-15-2006, 06:07 PM
I don't know if this helps, but keep this in mind ...

Once you define a variable, example $id ...
That variable is global. You can move from script-to-script
and $id remains as-is. That might be related to your problem,
where you are re-defining it instead of leaving it alone.

CFMaBiSmAd
11-15-2006, 06:31 PM
The hidden field with the id in it in the first code is not located within the <form...> </form> tags and won't be passed by the browser to the next page. Only data that is submitted by the browser using forms, or contained in parameters as part of the URL, or stored in sessions or cookies are available between pages.

mwm
11-22-2006, 03:35 PM
I have tried everything I could think of to get the id to pass consistenly. But the scripts still insert into the db a 0 instead of the correct id. This happens every once an a while. COULD SOME CORRECT ME ON WHAT I'M DOING WRONG. THANKS.
The two scripts are below


<?
session_start();
include "conn.php";
$community=$_POST['community'];
$id= $_POST['id'];
echo "Customer ID $id";

?>



<html>

<head><link rel=stylesheet type=text/css href=css/default.css>

</head>
<body>

<form action = "custhistory.php" method ="POST">

<h1><p align=center></p></h1>
<h3><p align=center>Home Buying Details</p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php">&nbsp;&nbsp;Main </a><a href="contactfirst1.php">&nbsp;&nbsp; Contacts </a>
<a href="custhistory.php">&nbsp;&nbsp; History </a>
</center>

<br>
<hr>

<?

echo "<input type = 'hidden' name = 'id' value = '$id'>";

$mysql = "SELECT * from cust where id = '$id' and community= '$community' ";




$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);



$id = $row[0];




$mysql1 = "SELECT date_format(regdate, '%M-%d-%Y'), fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where community= '$community' and id = '$id'";




$result1= mysql_query($mysql1) or die ("Can't connect");







echo "<table border=\"0\">";
echo "<th>Registered</th>";
echo "<th>Guest</th>";
echo "<th></th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";
echo "<th>Phone</th>";
echo "<th>Cell</th>";
echo "<th>Work</th>";
echo "<th>Email</th>";


$j = true;
while ($row = mysql_fetch_row($result1))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>
<?





$mysql2 = "SELECT status, level, adulthousehold,childhousehold,nameage from cust where community= '$community'and id = '$id'";

$result2= mysql_query($mysql2) or die ("Can't connect");







echo "<table border=\"0\">";
echo "<th>Status</th>";
echo "<th>Level</th>";
echo "<th>Adults</th>";
echo "<th>Children</th>";
echo "<th>Names</th>";


$j = true;
while ($row = mysql_fetch_row($result2))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>


<?



$mysql3 = "SELECT realname,realcomp,realadd,realphone from realtor where id = '$id'";




$result3= mysql_query($mysql3) or die ("Can't connect");
echo "<th>&nbsp;Realtor</th>";
echo "<table border=\"0\">";
$j = true;
while ($row = mysql_fetch_row($result3))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result3);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>


<hr>
<?

$query4 = ("SELECT * FROM cust where community = '$community' and id ='$id'");
$result4 = mysql_query($query4);
$row=mysql_fetch_row($result4);


?>


<p align = center></a><?echo $row[3]?> <?echo $row[4]?> is looking for a new home with </center>
<p align = center>2 Bedrooms <input = "checkbox" name ="twobed" value ="<? echo $row[23]?>" size = "1"> 3 Bedrooms <input = "checkbox" name ="threebed" value ="<? echo $row[24]?>" size = "1"> 4 Bedrooms <input = "checkbox" name ="fourbed" value ="<? echo $row[25]?>" size = "1"> 5 or more Bedrooms <input = "checkbox" name ="morebed" value ="<? echo $row[26]?>" size = "1"></p><p align = center> 1.5 Baths <input = "checkbox" name ="onebath" value ="<? echo $row[27]?>" size = "1"> 2 Baths <input = "checkbox" name ="twobaths" value ="<? echo $row[28]?>" size = "1"> 2.5 Baths <input = "checkbox" name ="twohalfbaths" value ="<? echo $row[29]?>" size = "1"> 3 Baths <input = "checkbox" name ="threebaths" value ="<? echo $row[30]?>" size = "1"></p><p align = center> 2 Car Garage <input = "checkbox" name ="twogarage" value ="<? echo $row[31]?>" size = "1"> 2.5 Car Garage <input = "checkbox" name ="twohalfgarage" value ="<? echo $row[32]?>" size = "1"> 3 Car Garage <input = "checkbox" name ="threegarage" value ="<? echo $row[33]?>" size = "1">
<hr>

<p align = center><?echo $row[3]?> presently </center>
<p align = center>Rent <input = "checkbox" name ="rent" value ="<? echo $row[59]?>" size = "1"> Own <input = "checkbox" name ="own" value ="<? echo $row[60]?>" size = "1"> Single Family <input = "checkbox" name ="family" value ="<? echo $row[61]?>" size = "1"> Multifamily <input = "checkbox" name ="multifamily" value ="<? echo $row[62]?>" size = "1"> Live with family <input = "checkbox" name ="livefamily" value ="<? echo $row[63]?>" size = "1">
<hr>
<p align = center>Price Range
<input type ="text" name="price" value = "<?echo $row[64]?>" size = "12"></textarea>
<p align = center>Move Time
<input type ="text" name="movetime" value = "<?echo $row[65]?>" size = "12"></textarea>
<hr>





<p align =center>
<a href="guestmain.php">Main</a></center>
</table>


</form>
</body>
</html>




<?
session_start();
include "conn.php";
session_register("id");
echo "Customer ID $id";

?>




<html>

<head><link rel=stylesheet type=text/css href=css/default.css>

</head>
<body>
<form action = "followupdate.php" method ="POST">
<h1><p align=center></p></h1>
<h3><p align=center>Guest History </p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php">&nbsp;&nbsp;Main </a><a href="contactfirst1.php">&nbsp;&nbsp; Contacts </a>
<?echo $row[11]?><a href="exceptionone.php">&nbsp;&nbsp; Exception Report <a href="contacteditfour.php">&nbsp;&nbsp; Status Change </a><a href="addtouch.php">&nbsp;&nbsp; Add Touch/Note </a><a href="earnestone.php">&nbsp;&nbsp; Earnest </a></center>
<input type = "hidden" name = "tpcount" value = "1">

<br>
<hr>




<?

echo "<input type = 'hidden' name = 'id' value = '$id'>";

$mysql = "SELECT * from cust where id = '$id'";




$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);

$id = $row[0];

$mysql1 = "SELECT fname,lname,address,city,state,zip,hphone,cphone,wphone, email from cust where id = '$id'";







$result1= mysql_query($mysql1) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Guest</th>";
echo "<th></th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";
echo "<th>Phone</th>";
echo "<th>Cell</th>";
echo "<th>Work</th>";
echo "<th>Email</th>";


$j = true;
while ($row = mysql_fetch_row($result1))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";






?>

<?

$mysql2 = "SELECT status,model,elevation,lot from cust where id = '$id'";



$result2= mysql_query($mysql2) or die ("Can't connect");





echo "<table border=\"0\">";
echo "<th>Status</th>";
echo "<th>Model</th>";
echo "<th>Elevation</th>";
echo "<th>Lot</th>";


$j = true;
while ($row = mysql_fetch_row($result2))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>

<hr>
<br>
<?

$mysql4 = "SELECT tpoint, date_format(tpdate, '%M-%d-%Y') from followup where id = '$id' order by tpdate";


$result4= mysql_query($mysql4) or die ("Can't connect");




echo "<table border=\"0\">";
echo "<th>Touch</th>";
echo "<th>Date</th>";


$j = true;
while ($row = mysql_fetch_row($result4))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result4);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>
<hr>
<br>
<?

$mysql6 = "SELECT demo, date_format(demodate, '%M-%d-%Y') from demotbl where id = '$id' order by demodate";


$result6= mysql_query($mysql6) or die ("Can't connect");




echo "<h4>";
echo "<table border=\"0\">";
echo "<th>Demo</th>";
echo "<th>Date</th>";
echo "</h4>";

$j = true;
while ($row = mysql_fetch_row($result6))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result6);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>
<hr>
<br>
<?

$mysql7 = "SELECT date_format(appdate, '%M-%d-%Y') from apptbl where id = '$id' order by appdate";


$result7= mysql_query($mysql7) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Appointments</th>";



$j = true;
while ($row = mysql_fetch_row($result7))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result7);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>

<?
echo "<center>Notes</center>";
$mysql5 = "SELECT * from followup where id = '$id'";

$result5= mysql_query($mysql5) or die ("Can't connect");

$num_results = mysql_num_rows($result5);



for ($i=0;$i<$num_results; $i++)


{



$row = mysql_fetch_array($result5);

echo "<center><table border='0' width='80%'> ";
echo "<tr><th align=left Width =80%></th></tr>";


echo "</td><td align=left>";
echo $row['6'];




echo "</td></tr>";
echo "</table>";



}

if ($num_results==0) echo "No Records";

?>




</form>
</body>
</html>

GeXus
11-22-2006, 04:19 PM
You are assigning ID from a post variable, do you have an input that is named ID?, I don't see it.

mwm
11-22-2006, 04:24 PM
No, the id is be pulled from the database in the first script. Thanks for taking the time to help me out.

GeXus
11-22-2006, 04:29 PM
Is the problem that the ID is not passing to the next page?

Are you posting to the second page? If so, on the second page (the one being posted to) assign $id to $_POST['id'], you don't need to use session register.. then if you want to turn the id value into a session variable, do $_SESSION['id'] = $id (or $_POST['id'])

mwm
11-22-2006, 04:33 PM
Yes, the id is not alway passed to the second script.

GeXus
11-22-2006, 04:36 PM
On the second page, replace
session_register("id");

with

$id = $_POST['id']

Then see if it echos

mwm
11-22-2006, 04:44 PM
OK I did and it won't echo..That is the strange thing. When i use the session id it will echo 90% of the time. The other 10% it won't. But when i use $id = $_POST['id'];
it doesn't echo at all.

GeXus
11-22-2006, 04:46 PM
On the first page, when you view source... for the id field, does it have a value?

mwm
11-22-2006, 04:50 PM
Yes, on the first page I have always been able to echo the id.

GeXus
11-22-2006, 04:56 PM
Not just echo the ID, but specifically that your field named 'id' has a value.. also remove all the extra spacing..

GeXus
11-22-2006, 04:59 PM
Do this.. create 2 pages, 1.php and 2.php

in 1.php put the following


<form action="2.php" method="post">
<input type="hidden" name="id" value="id value"/>
<input type="submit">
</form>


in 2.php put the following


<?
$id = $_POST['id'];
echo $id;
?>


Go to 1.php and hit submit... tell me if it echo's "id value"

mwm
11-22-2006, 05:01 PM
Sorry but maybe you lost me. How do I be sure that 'id' has a value. also spacing where.

GeXus
11-22-2006, 05:02 PM
Do the above first, then we'll get back to that.

meth
11-22-2006, 05:05 PM
$id = $_POST['id'] will not have a vlaue until the form is submitted, so when your page first executes you receive a "Undefined index:" notice. Hence your query will fail further down the script.

When the first page loads, you need to assign a value to $id that's accessible such as a $_GET or $_SESSION.

Turn on errors to E_ALL:
ini_set('error_reporting','E_ALL');

mwm
11-22-2006, 05:22 PM
Yes id value is echoed. So I don't lose anyone here. There are 4 scripts.

This one grabs the community from the db. This work as expected.

<?
session_start();
include "conn.php";
$community = $_POST['community'];
$id = $_POST['id'];
?>

<html>
<head><link rel=stylesheet type=text/css href=css/default.css></head>
<body>
<form name = "contactfirst1" form action = "contactwo1.php" method ="POST">
<h1><p align=center></p></h1>
<h3><p align=center><i>Choose Community</i></center></p></h3><h4>
<p align =center>
<a href="guestmain.php">Main</a>
<hr>

<br>
<br>
<br>
Community <? $query = mysql_query ("Select community from communties order by community ASC");
echo "<select name=\"community\" size=\"1\">\n";
for ($i=0;$i<mysql_numrows($query);$i++) {
echo "<option value=\"".mysql_result($query,$i,"community")."\">".mysql_result($query,$i,"community")."</option>\n";
}
echo"</select>\n";?>

<p><input type=Submit name=Submit style="font-size:15" value="Enter"> <p>
</form>
</body>
</html>

This one grabs the customer and id from the db . This also work as expected

<?
session_start();
include "conn.php";
$community=$_POST['community'];

?>

<html>
<head><link rel=stylesheet type=text/css href=css/default.css></head>
<body>
<form action="contactthree1.php" method="POST">
<input type = "hidden" name = "id" value = "<? echo $id;?>">
<h1><p align=center></p></h1>
<h3><p align=center><i>Choose Customer</i></p></h3>
<h3><p align=center></center></p></h3><h4>
<p align =center>
<a href="guestmain.php">Main</a>
<hr>
<br>
<br>
<br>
Community <input type = "text" name= "community" value="<? echo $community; ?>">

<?

$mysql="SELECT * from cust where community= '$community' order by lname ASC";

$query = mysql_query($mysql);
echo "Customer Name ";
echo "<select name=\"id\" size=\"1\">\n";
for ($i=0;$i<mysql_num_rows($query);$i++) {
echo "<option value=\"".mysql_result($query,$i,"id")."\">".mysql_result($query,$i,"lname")."</option>\n";

}
echo"</select>\n";

?>
<br>
<br>
<p><input type=Submit name=Submit style="font-size:15" value="Enter"> <p>
<input type=Reset style="font-size:15"value="Clear"/> </form>


<br>
</form>
</body>
</html>

This script pull the customer id from the db. This works every time


<?
session_start();
include "conn.php";
$community=$_POST['community'];
$id= $_POST['id'];
echo "Customer ID $id";

?>



<html>

<head><link rel=stylesheet type=text/css href=css/default.css>

</head>
<body>

<form action = "custhistory.php" method ="POST">

<h1><p align=center></p></h1>
<h3><p align=center>Home Buying Details</p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php">&nbsp;&nbsp;Main </a><a href="contactfirst1.php">&nbsp;&nbsp; Contacts </a>
<a href="custhistory.php">&nbsp;&nbsp; History </a>
</center>

<br>
<hr>

<?

echo "<input type = 'hidden' name = 'id' value = '$id'>";

$mysql = "SELECT * from cust where id = '$id' and community= '$community' ";




$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);



$id = $row[0];




$mysql1 = "SELECT date_format(regdate, '%M-%d-%Y'), fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where community= '$community' and id = '$id'";




$result1= mysql_query($mysql1) or die ("Can't connect");







echo "<table border=\"0\">";
echo "<th>Registered</th>";
echo "<th>Guest</th>";
echo "<th></th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";
echo "<th>Phone</th>";
echo "<th>Cell</th>";
echo "<th>Work</th>";
echo "<th>Email</th>";


$j = true;
while ($row = mysql_fetch_row($result1))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>
<?





$mysql2 = "SELECT status, level, adulthousehold,childhousehold,nameage from cust where community= '$community'and id = '$id'";

$result2= mysql_query($mysql2) or die ("Can't connect");







echo "<table border=\"0\">";
echo "<th>Status</th>";
echo "<th>Level</th>";
echo "<th>Adults</th>";
echo "<th>Children</th>";
echo "<th>Names</th>";


$j = true;
while ($row = mysql_fetch_row($result2))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>


<?



$mysql3 = "SELECT realname,realcomp,realadd,realphone from realtor where id = '$id'";




$result3= mysql_query($mysql3) or die ("Can't connect");
echo "<th>&nbsp;Realtor</th>";
echo "<table border=\"0\">";
$j = true;
while ($row = mysql_fetch_row($result3))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result3);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";



?>


<hr>
<?

$query4 = ("SELECT * FROM cust where community = '$community' and id ='$id'");
$result4 = mysql_query($query4);
$row=mysql_fetch_row($result4);


?>


<p align = center></a><?echo $row[3]?> <?echo $row[4]?> is looking for a new home with </center>
<p align = center>2 Bedrooms <input = "checkbox" name ="twobed" value ="<? echo $row[23]?>" size = "1"> 3 Bedrooms <input = "checkbox" name ="threebed" value ="<? echo $row[24]?>" size = "1"> 4 Bedrooms <input = "checkbox" name ="fourbed" value ="<? echo $row[25]?>" size = "1"> 5 or more Bedrooms <input = "checkbox" name ="morebed" value ="<? echo $row[26]?>" size = "1"></p><p align = center> 1.5 Baths <input = "checkbox" name ="onebath" value ="<? echo $row[27]?>" size = "1"> 2 Baths <input = "checkbox" name ="twobaths" value ="<? echo $row[28]?>" size = "1"> 2.5 Baths <input = "checkbox" name ="twohalfbaths" value ="<? echo $row[29]?>" size = "1"> 3 Baths <input = "checkbox" name ="threebaths" value ="<? echo $row[30]?>" size = "1"></p><p align = center> 2 Car Garage <input = "checkbox" name ="twogarage" value ="<? echo $row[31]?>" size = "1"> 2.5 Car Garage <input = "checkbox" name ="twohalfgarage" value ="<? echo $row[32]?>" size = "1"> 3 Car Garage <input = "checkbox" name ="threegarage" value ="<? echo $row[33]?>" size = "1">
<hr>

<p align = center><?echo $row[3]?> presently </center>
<p align = center>Rent <input = "checkbox" name ="rent" value ="<? echo $row[59]?>" size = "1"> Own <input = "checkbox" name ="own" value ="<? echo $row[60]?>" size = "1"> Single Family <input = "checkbox" name ="family" value ="<? echo $row[61]?>" size = "1"> Multifamily <input = "checkbox" name ="multifamily" value ="<? echo $row[62]?>" size = "1"> Live with family <input = "checkbox" name ="livefamily" value ="<? echo $row[63]?>" size = "1">
<hr>
<p align = center>Price Range
<input type ="text" name="price" value = "<?echo $row[64]?>" size = "12"></textarea>
<p align = center>Move Time
<input type ="text" name="movetime" value = "<?echo $row[65]?>" size = "12"></textarea>
<hr>





<p align =center>
<a href="guestmain.php">Main</a></center>
</table>


</form>
</body>
</html>



This is where the problem lies. The script above should pass the id to the script below. It will but only about 90% of the time. The other 10% it will not


<?
session_start();
include "conn.php";
session_register("id");
echo "Customer ID $id";

?>




<html>

<head><link rel=stylesheet type=text/css href=css/default.css>

</head>
<body>
<form action = "followupdate.php" method ="POST">
<h1><p align=center></p></h1>
<h3><p align=center>Guest History </p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php">&nbsp;&nbsp;Main </a><a href="contactfirst1.php">&nbsp;&nbsp; Contacts </a>
<?echo $row[11]?><a href="exceptionone.php">&nbsp;&nbsp; Exception Report <a href="contacteditfour.php">&nbsp;&nbsp; Status Change </a><a href="addtouch.php">&nbsp;&nbsp; Add Touch/Note </a><a href="earnestone.php">&nbsp;&nbsp; Earnest </a></center>
<input type = "hidden" name = "tpcount" value = "1">

<br>
<hr>




<?

echo "<input type = 'hidden' name = 'id' value = '$id'>";

$mysql = "SELECT * from cust where id = '$id'";




$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);

$id = $row[0];

$mysql1 = "SELECT fname,lname,address,city,state,zip,hphone,cphone,wphone, email from cust where id = '$id'";







$result1= mysql_query($mysql1) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Guest</th>";
echo "<th></th>";
echo "<th>Address</th>";
echo "<th>City</th>";
echo "<th>State</th>";
echo "<th>Zip</th>";
echo "<th>Phone</th>";
echo "<th>Cell</th>";
echo "<th>Work</th>";
echo "<th>Email</th>";


$j = true;
while ($row = mysql_fetch_row($result1))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";






?>

<?

$mysql2 = "SELECT status,model,elevation,lot from cust where id = '$id'";



$result2= mysql_query($mysql2) or die ("Can't connect");





echo "<table border=\"0\">";
echo "<th>Status</th>";
echo "<th>Model</th>";
echo "<th>Elevation</th>";
echo "<th>Lot</th>";


$j = true;
while ($row = mysql_fetch_row($result2))

{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>

<hr>
<br>
<?

$mysql4 = "SELECT tpoint, date_format(tpdate, '%M-%d-%Y') from followup where id = '$id' order by tpdate";


$result4= mysql_query($mysql4) or die ("Can't connect");




echo "<table border=\"0\">";
echo "<th>Touch</th>";
echo "<th>Date</th>";


$j = true;
while ($row = mysql_fetch_row($result4))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result4);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>
<hr>
<br>
<?

$mysql6 = "SELECT demo, date_format(demodate, '%M-%d-%Y') from demotbl where id = '$id' order by demodate";


$result6= mysql_query($mysql6) or die ("Can't connect");




echo "<h4>";
echo "<table border=\"0\">";
echo "<th>Demo</th>";
echo "<th>Date</th>";
echo "</h4>";

$j = true;
while ($row = mysql_fetch_row($result6))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result6);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>
<hr>
<br>
<?

$mysql7 = "SELECT date_format(appdate, '%M-%d-%Y') from apptbl where id = '$id' order by appdate";


$result7= mysql_query($mysql7) or die ("Can't connect");






echo "<table border=\"0\">";
echo "<th>Appointments</th>";



$j = true;
while ($row = mysql_fetch_row($result7))


{
if($j)
$j= false;

else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result7);$i++) {
if ($j) {

echo "<td bgcolor=\"#CCFF99\">";

}
if (!$j) {

echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";

}

}
echo "</table>";

?>

<?
echo "<center>Notes</center>";
$mysql5 = "SELECT * from followup where id = '$id'";

$result5= mysql_query($mysql5) or die ("Can't connect");

$num_results = mysql_num_rows($result5);



for ($i=0;$i<$num_results; $i++)


{



$row = mysql_fetch_array($result5);

echo "<center><table border='0' width='80%'> ";
echo "<tr><th align=left Width =80%></th></tr>";


echo "</td><td align=left>";
echo $row['6'];




echo "</td></tr>";
echo "</table>";



}

if ($num_results==0) echo "No Records";

?>




</form>
</body>
</html>

GeXus
11-22-2006, 05:29 PM
You need to go through your script.. on each page.. view source from the browser.. make sure that all your input fields (specifically id) are populated correctly in the actual source.. If they are, then get rid of the session stuff, unless there is more you will be doing. But for now just use post variables, as I mentioned above. Then like meth said, put ini_set('error_reporting','E_ALL'); at the top of all your pages.

CFMaBiSmAd
11-22-2006, 05:50 PM
In the set of code you posted above (please edit that post and use the php code wrappers), you do a query and set $id to some new value -

$mysql = "SELECT * from cust where id = '$id' and community= '$community' ";
$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);
$id = $row[0];This query could be returning zero rows, in which case $id will be set to a NULL. I recommend some error checking and echoing to see what is going on at this point in the code.

mwm
11-22-2006, 06:09 PM
Ok did what you said. Still do the same thing. Any other suggestions?

Thanks

mwm
11-22-2006, 06:13 PM
As a test I have just tried to echo out the id on each page. Well from the third to fourth script it will drop the id about 9 out of 10 times and nothing shows up. HOW STRANGE. Any other suggestions?

Thanks

meth
11-22-2006, 06:32 PM
In your first script, change:



$community = $_POST['community'];
$id = $_POST['id'];


to:



if ( isset($_POST['Submit']) ) {
$id = ( isset($_POST['id']) ) ? $_POST['id'] : false;
$community = ( isset($_POST['community']) ) ? $_POST['community'] : false;
if ($id && $community) {
$_SESSION['id'] = $id;
$_SESSION['community'] = $community;
}
}


Once the form submits with values for the id and community inputs, sessions are set for both. Just be sure that the first page does not submit to the second unless there are valid values in the form values. These sessions should be used for $id and $community throughout the remaining scripts via code at the top of each subsequent page:



$id = $_SESSION['id'];
$community = $_SESSION['community'];


not:


$community=$_POST['community'];
$id= $_POST['id'];


In your 3rd script, change:


$id = $row[0];

$mysql1 = "SELECT date_format(regdate, '%M-%d-%Y'), fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where community= '$community' and id = '$id'";


to



$this_id = $row[0];

$mysql1 = "SELECT date_format(regdate, '%M-%d-%Y'), fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where community= '$community' and id = $this_id";


Lastly, after each test, kill your session with at least session_destroy();



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum