Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying error with PHP? 1

Status
Not open for further replies.

gillrowley

Programmer
Apr 2, 2004
59
US
If someone could visit the following link - and then click on Rover (or Spot - doesn't matter) and tell me why on earth the following characters are displayed: ",`r0".

What this is doing is grabbing information from a MySQL database and displaying it on the page. However, nowhere in my code (php or html) or in the database do I have those characters. I've never seent his anywhere else.

The page was developed with Dreamweaver MX2004. Thanks.
Gill
 
Could you post the PHP code you are using please.
remeber to surround it with [ignore]
Code:
[/ignore] tags when you do.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Here's the code:

<?php
$get_dogs_sql = "SELECT *, stateName FROM availabledogs ";
$get_dogs_sql .= "INNER JOIN states on state = stateCode ";
$get_dogs_sql .= "ORDER BY state, dogName";
$get_dogs_res = mysql_query($get_dogs_sql);
if (mysql_num_rows($get_dogs_res) > 0) {
$display = "<table cellpadding=1 cellspacing=0 border=0 width=\"100%\">";
$display .= "<tr><th>Dog</th><th>State</th><th>Rescue Contact</th></tr>";
while ($get_info = mysql_fetch_array($get_dogs_res)) {
$dog_id = $get_info['dogID'];
global $dog_id;
$dogName = $get_info['dogName'];
$state = $get_info['stateName'];
$rcontact = $get_info['rescueContact'];
$display .= "<tr>";
$display .= "<td><a href=\"".$_SERVER['PHP_SELF']."?dog_id=".$dog_id."\">".$dogName."</a></td>";
$display .= "<td>".$state."</td><td>".$rcontact."</td>";
$display .= "</tr>";
}
$display .= "</table>";
$display .= "<br><br><br>";
$display .= "<a href=\"adoption_application.php\">Click here to start the adoption process.</a>";
} else {
$display = "<p>Sorry, there are no dogs available at this time.</p>";
}
mysql_free_result($get_dogs_res);
echo $display;


echo "</div>";
echo "<div class=\"content_half_right\">";
if (isset($_GET["dog_id"])) {
$dog_info_query = "SELECT * FROM availabledogs WHERE dogID = ".$_GET["dog_id"];
$dog_info_res = mysql_query($dog_info_query);
$get_dog_info = mysql_fetch_array($dog_info_res);
$dogName = $get_dog_info['dogName'];
$dogColor = $get_dog_info['dogColor'];
$dogWeight = $get_dog_info['dogWeight'];
$dogAge = $get_dog_info['dogAge'];
if ($get_dog_info['housebroken']) {
$housebroken = "Yes";
} else {
$housebroken = "No";
}
if ($get_dog_info['leashTrained']) {
$leashTrained = "Yes";
} else {
$leashTrained = "No";
}
if ($get_dog_info['crateTrained']) {
$crateTrained = "Yes";
} else {
$crateTrained = "No";
}
$imagePath = $get_dog_info['imagePath'];
$contact = $get_dog_info['rescueContact'];
$contactEmail = $get_dog_info['contactEmail'];
$contactPhone = $get_dog_info['contactPhone'];
$gender = $get_dog_info['gender'];
$narrative = $get_dog_info['narrative'];
$result = "<h2>".$dogName."</h2>";
$result .= "<table cellpadding=0 cellspacing=0 border=0 width=100%>";
$result .= "<tr><td>Gender:</td><td>".$gender."</td>";
$result .= "<td rowspan=8 valign=\"top\">";
$result .= "<a href=\"".$imagePath."\" target=\"_blank\"><img src=\"".$imagePath."\" border=0 width=\"75\" height=\"56\"></a></td>";
$result .= "</tr>";
$result .= "<tr><td>Color</td><td>".$dogColor."</td></tr>";
$result .= "<tr><td>Weight</td><td>".$dogWeight."</td></tr>";
$result .= "<tr><td>Age</td><td>".$dogAge."</td></tr>";
$result .= "<tr><td>Housebroken?</td><td>".$housebroken."</td></tr>";
$result .= "<tr><td>Leash Trained?</td><td>".$leashTrained."</td></tr>";
$result .= "<tr><td>Crate Trained</td><td>".$crateTrained."</td></tr>";
$result .= "<tr><td>Rescue Contact</td><td>".$contact."</td></tr>";
$result .= "<tr><td>Email</td><td colspan=2><a href=\"mailto:".$contactEmail."\">".$contactEmail."</a></td></tr>";
$result .= "<tr><td>Phone Number</td><td colspan=2>".$contactPhone."</td></tr>";
$result .= "<tr><td colspan=3>"&nbsp;"</td></tr>";
$result .= "<tr><td colspan=3>".$narrative."</td></tr>";
$result .= "</table>";
echo $result;
}
?>
 
Code:
<?php 
				$get_dogs_sql = "SELECT *, stateName FROM availabledogs ";
				$get_dogs_sql .= "INNER JOIN states on state = stateCode ";
				$get_dogs_sql .= "ORDER BY state, dogName";
				$get_dogs_res = mysql_query($get_dogs_sql);
				if (mysql_num_rows($get_dogs_res) > 0) {
					$display = "<table cellpadding=1 cellspacing=0 border=0 width=\"100%\">";
					$display .= "<tr><th>Dog</th><th>State</th><th>Rescue Contact</th></tr>";
					while ($get_info = mysql_fetch_array($get_dogs_res)) {
						$dog_id = $get_info['dogID'];
						global $dog_id;
						$dogName = $get_info['dogName'];
						$state	= $get_info['stateName'];
						$rcontact = $get_info['rescueContact'];
						$display .= "<tr>";
						$display .= "<td><a href=\"".$_SERVER['PHP_SELF']."?dog_id=".$dog_id."\">".$dogName."</a></td>";
						$display .= "<td>".$state."</td><td>".$rcontact."</td>";		
						$display .= "</tr>";
					}
					$display .= "</table>";
					$display .= "<br><br><br>";
					$display .= "<a href=\"adoption_application.php\">Click here to start the adoption process.</a>";
				} else {
					$display = "<p>Sorry, there are no dogs available at this time.</p>";
				}
				mysql_free_result($get_dogs_res);
				echo $display;	
			
			
			echo "</div>";
			echo "<div class=\"content_half_right\">";			
				if (isset($_GET["dog_id"])) {
					$dog_info_query = "SELECT * FROM availabledogs WHERE dogID = ".$_GET["dog_id"];
					$dog_info_res = mysql_query($dog_info_query);
					$get_dog_info = mysql_fetch_array($dog_info_res);
					$dogName = $get_dog_info['dogName'];
					$dogColor = $get_dog_info['dogColor'];
					$dogWeight = $get_dog_info['dogWeight'];
					$dogAge = $get_dog_info['dogAge'];
					if ($get_dog_info['housebroken']) {
						$housebroken = "Yes";
					} else {
						$housebroken = "No";
					}		
					if ($get_dog_info['leashTrained']) { 
						$leashTrained = "Yes"; 
					} else {
						$leashTrained = "No";
					}
					if ($get_dog_info['crateTrained']) { 
						$crateTrained = "Yes"; 
					} else {
						$crateTrained = "No";
					}
					$imagePath = $get_dog_info['imagePath'];							
					$contact = $get_dog_info['rescueContact'];
					$contactEmail = $get_dog_info['contactEmail'];
					$contactPhone = $get_dog_info['contactPhone'];
					$gender = $get_dog_info['gender'];
					$narrative = $get_dog_info['narrative'];
					$result = "<h2>".$dogName."</h2>";
					$result .= "<table cellpadding=0 cellspacing=0 border=0 width=100%>";
					$result .= "<tr><td>Gender:</td><td>".$gender."</td>";
					$result .= "<td rowspan=8 valign=\"top\">";
					$result .= "<a href=\"".$imagePath."\" target=\"_blank\"><img src=\"".$imagePath."\" border=0 width=\"75\" height=\"56\"></a></td>";
					$result .= "</tr>";
					$result .= "<tr><td>Color</td><td>".$dogColor."</td></tr>";
					$result .= "<tr><td>Weight</td><td>".$dogWeight."</td></tr>";
					$result .= "<tr><td>Age</td><td>".$dogAge."</td></tr>";
					$result .= "<tr><td>Housebroken?</td><td>".$housebroken."</td></tr>";
					$result .= "<tr><td>Leash Trained?</td><td>".$leashTrained."</td></tr>";
					$result .= "<tr><td>Crate Trained</td><td>".$crateTrained."</td></tr>";					
					$result .= "<tr><td>Rescue Contact</td><td>".$contact."</td></tr>";	
					$result .= "<tr><td>Email</td><td colspan=2><a href=\"mailto:".$contactEmail."\">".$contactEmail."</a></td></tr>";
					$result .= "<tr><td>Phone Number</td><td colspan=2>".$contactPhone."</td></tr>";
					$result .= "<tr><td colspan=3>"&nbsp;"</td></tr>";
					$result .= "<tr><td colspan=3>".$narrative."</td></tr>";
					$result .= "</table>";
					echo $result;	
				}									
			?>
 
Gill

this is NOT the code that generates the page you pointed us to.

the page above (live) has the table tag in the content_half_right formed like this
Code:
<table border="0" cellpadding="0" cellspacing="0" width="100%">

whereas what you posted above has teh attributes in a different order.

we need the real mccoy if we're going to be able to help.
 
The code I posted here is from the page I ftp-ed to the site about a minute before I started this post. I don't know what else to give you.
 
I believe this is the line that is causing the problem:

Code:
 $result .= "<tr><td colspan=3>[red]"&nbsp;"[/red]</td></tr>";

remove the 2 sets of quotation marks in red.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
change this line
Code:
   $result .= "<tr><td colspan=3>"&nbsp;"</td></tr>";
to
Code:
   $result .= "<tr><td colspan=3>&nbsp;</td></tr>";
that will fix it.

and make sure that all your html attributes are enclosed in quotes.

ie. cellpadding="0" etc
 
is that not what i said?

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Great minds think alike, and uhh at the same time??? ;)

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top