I have the following script but the page does not load. It always loads the error page. -
<?php
-
if ($c !="") {
-
include ("content".$c.".php");
-
} else {
-
include ("content4.8.php");
-
}
-
?>
9 1779
I have the following script but the page does not load. It always loads the error page. -
<?php
-
if ($c !="") {
-
include ("content".$c.".php");
-
} else {
-
include ("content4.8.php");
-
}
-
?>
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
I added the script and i get following error
Parse error: syntax error, unexpected '$' in E:\inetpub\vhosts\mywebsite.com\httpdocs\i\index.p hp on line 48
line 48 is where i put the script.
so what else can be the problem
Atli 5,058
Expert 4TB
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.
-
<html>
-
<head>
-
<!-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>
-
<meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0)">
-
<title>Impact international</title>
-
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
-
<!-- Fireworks MX Dreamweaver MX target. Created Thu Aug 14 16:48:00 GMT+0900 (???? (?W?€??)) 2003-->
-
<!--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-->
-
-
<script language="JavaScript1.2" src="navi.js"></script>
-
<script language="JavaScript1.2" src="mm_menu.js"></script>
-
<link href="base.css" rel="stylesheet" type="text/css">
-
<link href="text.css" rel="stylesheet" type="text/css">
-
<link href="product.css" rel="stylesheet" type="text/css">
-
<link href="footer.css" rel="stylesheet" type="text/css">
-
<link href="menu.css" rel="stylesheet" type="text/css">
-
</head>
-
<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')">
-
<p class="copyright">
-
<script language="JavaScript1.2">mmLoadMenus();</script>
-
</p>
-
<?php require("menu.php"); ?>
-
<table width="800" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
-
<tr>
-
<td width="161" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF" class="gray-back-left" >
-
-
<p> </p>
-
<?php
-
die(var_dump(c$));
-
if ($c != "") {
-
include("content".$c.".php");
-
} else {
-
include("content4.11.4.php");
-
}
-
?>
-
</td>
-
</tr>
-
</table>
-
<?php require("footer.php"); ?>
-
</body>
-
</html>
-
This is the whole page.
wbr
Atli 5,058
Expert 4TB
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.
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
...
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.
Atli 5,058
Expert 4TB
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_globals 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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
by: tshad |
last post by:
In my User control, I tried to do this:
***************************************************************************
<Script runat="server">
Public ClientName As String = "<!-- #include file =...
|
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...
|
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...
|
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"...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |