473,715 Members | 6,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Include code displaying wrong error file

5 New Member
I have the following script but the page does not load. It always loads the error page.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.          if ($c !="") {
  3.              include ("content".$c.".php");
  4.          } else {
  5.             include ("content4.8.php");
  6.         }
  7.        ?>
Aug 9 '08 #1
9 1793
dlite922
1,584 Recognized Expert Top Contributor
I have the following script but the page does not load. It always loads the error page.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.          if ($c !="") {
  3.              include ("content".$c.".php");
  4.          } else {
  5.             include ("content4.8.php");
  6.         }
  7.        ?>
I'm assuming content4.8.php is the "error page".

just before the if statement write die(var_dump($c ));

it will stop the script and tell you what type of variable $c is and what's in it.

Your problem is most likely elsewhere.

Make sure $c always gets set to something.



Dan
Aug 9 '08 #2
tonyadams5
5 New Member
I added the script and i get following error

Parse error: syntax error, unexpected '$' in E:\inetpub\vhos ts\mywebsite.co m\httpdocs\i\in dex.php on line 48

line 48 is where i put the script.

so what else can be the problem
Aug 10 '08 #3
Atli
5,058 Recognized Expert Expert
The problem revolves around the $c variable. It is most likely not being set properly. Please post the code that sets the $c variable.

To find out if your $c variable's value is what you would expect it to be, print it as the code is executed.
Like Dan suggested; you can do that by using the var_dump function in the line before the if statement.

Make sure the syntax is correct!
If you get parse errors, like the one you showed in your last post, the syntax is incorrect. If your having problems with it, post it here so we can take a look.
Aug 10 '08 #4
tonyadams5
5 New Member
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <!-onMouseover Link CSS Script-c Dynamic Drive (www.dynamicdrive.com). For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use, visit dynamicdrive.com--><style><!--a:hover{color:ffffff; background-color:0066ff; }--></style>
  4. <meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0)">
  5. <title>Impact international</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
  7. <!-- Fireworks MX Dreamweaver MX target.  Created Thu Aug 14 16:48:00 GMT+0900 (???? (?W?€??)) 2003-->
  8. <!--Special Effects upon page enter credit- Dynamic Drive (www.dynamicdrive.com) For full source code, installation instructions, 100's more free DHTML Scripts, and Terms Of Use, visit dynamicdrive.com-->
  9.  
  10. <script language="JavaScript1.2" src="navi.js"></script>
  11. <script language="JavaScript1.2" src="mm_menu.js"></script>
  12. <link href="base.css" rel="stylesheet" type="text/css">
  13. <link href="text.css" rel="stylesheet" type="text/css">
  14. <link href="product.css" rel="stylesheet" type="text/css">
  15. <link href="footer.css" rel="stylesheet" type="text/css">
  16. <link href="menu.css" rel="stylesheet" type="text/css">
  17. </head>
  18. <body bgcolor="#ffffff" link="#000000" vlink="#000000" alink="#000000"  onLoad="MM_preloadImages('image-top-header/top-header_r2_c4_f2.gif','image-top-header/top-header_r2_c6_f2.gif','image-top-header/top-header_r2_c8_f2.gif','image-top-header/top-header_r2_c12_f2.gif','image-top-header/top-header_r2_c14_f2.gif','image-top-header/top-header_r2_c16_f2.gif')">
  19. <p class="copyright"> 
  20.   <script language="JavaScript1.2">mmLoadMenus();</script>
  21. </p>
  22. <?php require("menu.php"); ?>
  23. <table width="800" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
  24.   <tr> 
  25.     <td width="161" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF" class="gray-back-left" > 
  26.  
  27.   <p>&nbsp;</p>
  28.       <?php
  29.                   die(var_dump(c$));
  30.                   if ($c != "") {
  31.                      include("content".$c.".php");
  32.                   } else {
  33.                      include("content4.11.4.php");
  34.                   }
  35.                ?>
  36.       </td>
  37.   </tr>
  38. </table>
  39. <?php require("footer.php"); ?>
  40. </body>
  41. </html>
  42.  
This is the whole page.

wbr
Aug 10 '08 #5
Atli
5,058 Recognized Expert Expert
I'm kind of get the feeling your not even paying attention to what you are doing...

The die() line you added contains the most basic of errors. If you were really looking for it, you should be able to spot it without any problems. (Not to mention that Dan posted the correct syntax earlier).

And that code doesn't contain anything that is meant to set the $c variable. What is that variable supposed to be? Where is it getting it's value from?

P.S.
Please post all code examples inside [code] tags.
Thanks.
Aug 10 '08 #6
tonyadams5
5 New Member
i am new in this so i need more help.

i received this page and was asked to correct it.

It seems that the main page links to this page and the c$ will the content required. I think the c$ value should come from address bar. So it seems that there is no command to get the c$ i.e. why the default page appears.

typical address will be

www.mywebsite.com/index.php?c=4.1


wbr
Aug 10 '08 #7
andrewmalachel
1 New Member
...
typical address will be

www.mywebsite.com/index.php?c=4.1
...
the url address "www.mywebsite. com/index.php?c=4.1 " means that your php files ("index.php" )
are using the "HTTP GET" method using parameter "c" that had the value "4.1"

now, you can retrieve the "c" value ("4.1") to your "$c" variable using the "$_GET[par]" variable to your "$c" variable.
you can change par with the GET parameter (in this case: "c")
so it goes like

$c = $_GET["c"];

now your "$c" variable has value and var.type...

o yeah, also you can remove the "die(var_dump() )" line since it's purpose is only to stop the codes and collect the "$c" value and var type.

sorry if my English is not very fluent... because I'm still learning 'how-to-use' that language... LoL

thx

.dee.
Aug 10 '08 #8
Atli
5,058 Recognized Expert Expert
i am new in this so i need more help.

i received this page and was asked to correct it.

It seems that the main page links to this page and the c$ will the content required. I think the c$ value should come from address bar. So it seems that there is no command to get the c$ i.e. why the default page appears.

typical address will be

www.mywebsite.com/index.php?c=4.1


wbr
Ok. For the record, your parse error was caused by you mixing up the variable name.
Variable names start with a dollar-sign ($), followed by the name of the variable.
So your c$ variable should have been $c.

As to the original problem. I'm guessing that this code you were asked to fix was written for an old version of PHP, like PHP4.

In PHP4 (and earlier) HTTP request variables would be automatically created for you to use in your code. (see the register_global s directive).
That is; using a URL like this: "index.php?c=4. 1"
the value of c, in this case 4.1, would be put into the $c variable automatically.

In PHP5, however, this feature was disabled due to security reasons.
Now you will have to fetch them via the $_GET super-global, as the previous poster suggested.
Aug 10 '08 #9
tonyadams5
5 New Member
Yes

Tks for the help. With the GET command, was able to get the $c and now the page works perfectly.

As mentioned earlier by posts, the site was created for php4.1 whereas the server is php4.4.7. So with the get command, the page is properly functioning.

wbr
Aug 11 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2218
by: bjam | last post by:
Hi, today I was able to abstract out into a separate xsl file a template that I specifically perform a call templates for, this worked with import no problem. However, when trying to do the same operation with a template that I use a match template on, IE was giving me the following error for the style sheet. Does anyone know how to import or include a match template versus a call named template? Thanks in advance for your help The...
6
4450
by: Christopher | last post by:
What is the syntax for including files from another directory? In my case I want to include a file called "error.h" which lies in a directory called "support" which is a directory inside the (project/solution/source or whatever you may call it) directory. it looks like this (hope the ascii comes out) dir engine_x .....dir support ..............file error.h ..............file error.cpp
6
4342
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
5
2507
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when dealing with complex software distributions. It occurs ot me that by extending the C include...
6
2123
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file = ...\includes\StaffingHeaders.inc -->" </Script> <%=ClientName%> ****************************************************************************
9
5546
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash shell pieces like this: <pre><code> #!/bin/sh ftp -i -n ftp.server.com&lt; &lt;EOF user username password epsv4 cd /
5
4063
by: Viken Karaguesian | last post by:
Hello all, I've used the SSI Include command successfully in the past to include frequently used files that are based within my own site. However, what if I was to use a file located in a differnt location - a different site altogether? I've Googled different variations of "how to insert an URL using #include" but all of the sites that came up never got beyond "file=" and "virtual=". There may be no more to it that that, but I'm not
5
2225
by: Tio | last post by:
I have project in MFC(vc++) . There are files and classes: classes:dialog1,dialog2,aaa,bbb ---------------------- main.cpp --------------------- #include "mainfrm.h" #include "dialog1.h" #include "dialog2.h"
1
5475
by: escort | last post by:
I am trying to include a file in my existing asp file. I am using business vista and I am getting following error This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying. For more information about HTTP errors, see Help. I know this is due to include file because once I take it off it works fine. I removed all the code from my file except...
0
8823
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.