PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 9th, 2004, 04:16 AM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 117 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 29 sec
Reputation Power: 6
unknown code inserted

Hi guys,

have two files with me..
a.php and b.php

actually a.php file is a file that consist all db connection and fetch array stuff where as the b.php file is the template/theme file that used to display the info obtained from the query..

b is included in a.php file..

when i view the file from the browser, i found that my output only appeared after a few line breaks that were not inserted by myself..

code appeared when i view source from the browser :
<p>&nbsp;</p>
<p>&nbsp;</p>
<html>
...


could u guys give me an idea what actually caused this problem and what should i do to remove this code ??? it is caused by my php code or what ??

please advise.

Reply With Quote
  #2  
Old July 9th, 2004, 06:47 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
This kind of thing is very hard to diagnose without seeing the code in question. If you could post your php files here (as attachments) I'm sure someone can take a look for you.

-KM-

Reply With Quote
  #3  
Old July 9th, 2004, 08:07 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
THis looks to me like something that some sort of editing program might insert. Zend, for example, inserts linebreaks if you hit shift-return. It wouldn't surprise me to find out that Dreamweaver or similar programs do something similar and that you've inadvertently added such code to your files with a mistaken keystroke.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #4  
Old July 9th, 2004, 08:36 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
for some reason. Sometimes. If there is linebreaks (/n - NOT <BR>) before the real code. (before the <?PHP ?> tag) this is interperted as a break <br> or <p/>.

- Pheifel

Reply With Quote
  #5  
Old July 9th, 2004, 10:40 PM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 117 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 29 sec
Reputation Power: 6
please check my code :

a.php
Code:
<?
$exists = file_exists("name.php");

if ($exists) { 

     include("name.php");
     $id = $i; 

     include("../include/db.php");
     mysql_connect("", $user, $pass) or die("Unable to connect to database");
     mysql_select_db("mysite_db") or die("Unable to connect to database");

     $sql = mysql_query("SELECT * FROM general WHERE id = '$id'");
     $myrow = mysql_fetch_array($sql);

     $sql2 = mysql_query("SELECT * FROM home WHERE id = '$id'");
     $myrow2 = mysql_fetch_array($sql2);

     $sql3 = mysql_query("SELECT * FROM home WHERE id = '$id'");
     $myrow3 = mysql_fetch_array($sql3);

	 $template = mysql_query("SELECT * FROM template WHERE id = '$id'");
     $row = mysql_fetch_array($template);

     mysql_close();

     if ($myrow['activate'] == "") {
          echo "<html><head><title>mysite.com</title></head><body>";
          echo "<p><div align=\"center\">";
          echo "Your account has not been activated yet.<br>";
          echo "In the meanwhile, do feel free to browse our web site at ";
          echo "<a href=\"http://mysite\">www.mysite.com</a>";
          echo "</div></p></body></html>";
          exit; 
     }

     if ($myrow && $myrow2) {

          if ($myrow['home_status'] == "Published") {

              $theme = $myrow['overall_style'];

              $style = $myrow2['style'];

              $tracker = $myrow2['tracker'];

          } else {

              $theme = "default.php";

         }
    include("../../templates/theme/b.php");

     } else {

          echo "<b>Error: Home Page Database Not Found.</b><br>";
          echo "Please contact the webmaster at ";
          echo "<a href=\"mailto:enquiries@mysite.com?\">enquiries@mysite.com</a>";

     }

} else {

echo "<b>Error HP: File Not Found.</b><br> Please contact the webmaster ";
echo "at <a href=\"mailto:enquiries@mysite.com?\">enquiries@mysite.com</a>"; 

}
?> 




b.php
Code:
<html>
<head>
<title><? echo $myrow['title']; ?></title>
<meta name="description" content="<? echo $myrow['description']; ?>">
<meta name="keywords" content="<? echo $myrow['keywords']; ?>">
<meta name="author" content="<? echo $myrow['author']; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
....


whats wrong with my code ????

please advise.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > unknown code inserted


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT