Jump to content

Internet Explorer 7 hates my simple PHP code


anthonydamasco

Recommended Posts

Hey everyone.

 

I have a simple php script that was working fine until my company upgraded to IE7. IE7 just shows the background and nothing else.

 

It works on EI6, and firefox

 

	          <?php

$conn = mysql_connect("localhost","user","user") or die ( mysql_error() );
$db = mysql_select_db("ACCU") or die ( mysql_error() );


$search=$_POST["search"];
$result = mysql_query("SELECT * FROM phonelist");
$num = mysql_num_rows($result);
if ($num == "0"){
echo "Please revise your search.";
}else{
while($r=mysql_fetch_array($result))
{	
  
   $phoneid=$r["idphonelist"];
   $name=$r["name"];
   $ext=$r["ext"];
   $dept=$r["department"];
   $cell=$r["cellphone"];

   echo "
  <table width=\"515\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#FFFFFF\">
  <tr>
    <td><table width=\"515\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
      <tr>
        <td width=\"178\">$name</td>
        <td width=\"40\">$ext</td>
        <td width=\"212\">$dept </td>
        <td width=\"85\">$cell</td>
      </tr>
    </table></td>
  </tr>
</table>
   ";
}
}
?>

 

any ideas.

Try this,

 

I always escape from php when im ouputting alot of information. and then just echo the values.

 

		          <?php

$conn = mysql_connect("localhost","user","user") or die ( mysql_error() );
$db = mysql_select_db("ACCU") or die ( mysql_error() );


$search=$_POST["search"];
$result = mysql_query("SELECT * FROM phonelist");
$num = mysql_num_rows($result);
if ($num == "0"){
echo "Please revise your search.";
}else{
while($r=mysql_fetch_array($result))
{	
 
  $phoneid=$r["idphonelist"];
  $name=$r["name"];
  $ext=$r["ext"];
  $dept=$r["department"];
  $cell=$r["cellphone"];

?>
 <table width="515" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
 <tr>
   <td><table width="515" border="0" cellpadding="0" cellspacing="0">
     <tr>
       <td width="178"><?php echo $name; ?></td>
       <td width="40"><?php echo $ext; ?></td>
       <td width="212"><?php echo $dept; ?> </td>
       <td width="85"><?php echo $cell; ?></td>
     </tr>
   </table></td>
 </tr>
</table>
<?php
   }
}
?>

Try this,

 

I always escape from php when im ouputting alot of information. and then just echo the values.

 

		          <?php

$conn = mysql_connect("localhost","user","user") or die ( mysql_error() );
$db = mysql_select_db("ACCU") or die ( mysql_error() );


$search=$_POST["search"];
$result = mysql_query("SELECT * FROM phonelist");
$num = mysql_num_rows($result);
if ($num == "0"){
echo "Please revise your search.";
}else{
while($r=mysql_fetch_array($result))
{	
  
   $phoneid=$r["idphonelist"];
   $name=$r["name"];
   $ext=$r["ext"];
   $dept=$r["department"];
   $cell=$r["cellphone"];

?>
  <table width="515" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
  <tr>
    <td><table width="515" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="178"><?php echo $name; ?></td>
        <td width="40"><?php echo $ext; ?></td>
        <td width="212"><?php echo $dept; ?> </td>
        <td width="85"><?php echo $cell; ?></td>
      </tr>
    </table></td>
  </tr>
</table>
<?php
    }
}
?>

You wouldn't actually have to echo them, you could use

<?= $cell; ?> 

instead of

<?php echo $cell; ?>

It's still doing the same thing to me after I tried escaping from php

 

       <?php

$conn = mysql_connect("localhost","www2","accuoffice") or die ( mysql_error() );
$db = mysql_select_db("ACCU") or die ( mysql_error() );


$search=$_POST["search"];
$result = mysql_query("SELECT * FROM phonelist");
$num = mysql_num_rows($result);
if ($num == "0"){
echo "Please revise your search.";
}else{
while($r=mysql_fetch_array($result))
{	
  
   $phoneid=$r["idphonelist"];
   $name=$r["name"];
   $ext=$r["ext"];
   $dept=$r["department"];
   $cell=$r["cellphone"];

   ?>
  <table width="515" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
  <tr>
    <td><table width="515" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="178"><?php print $name; ?></td>
        <td width="40"><?php print $ext; ?></td>
        <td width="212"><?php print $dept; ?></td>
        <td width="85"><?php print $cell; ?></td>
      </tr>
    </table></td>
  </tr>
</table>
  <?php
}
}
?>

You're code works fine for me in IE7, so there may be something else in other parts of you script that is causing the problems.

 

Here's some code that does what you're nested tables do, without the tables:

<div style="width:526px;border:1px solid black;display:block;clear:both;">
	<span style="width:178px;float:left;border:1px solid red"><?php echo $name; ?></span>
	<span style="width:40px;float:left"><?php echo $ext; ?></span>
	<span style="width:212px;float:left"><?php echo $dept; ?> </span>
	<span style="float:left"><?php echo $cell; ?></span>
	<div style="clear:both;line-height:0.01"> </div>
</div>

 

Try it and see if the problem still occurs.

 

Ken

  • 3 months later...

OMG! I just solved my problem... I feel so stupid :)

 

i was doing this...

 

in firefox i have a link button in favorities that loads the site with the correct test server url http://localhost/... etc.

 

BUT when  i was trying to view the same site with ie7 i was just doing a right click in index.php of my site and then open with -> internet explorer. That makes the url being sth like C:\wamp\www\... so test server wasn't working.

 

All fine now... :)

 

   

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.