By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

My PHP website

P: 21
I built a website using php ... but there is a problem .. the post variable pg is always=='"".. can some one correct the problem(s)?

We do not want an extra load on the server, so I disabled the download link - moderator
Feb 24 '08 #1
Share this Question
Share on Google+
10 Replies


Markus
Expert 5K+
P: 6,050
I built a website using php ... but there is a problem .. the post variable pg is always=='"".. can some one correct the problem(s)?
Download zip containing source files
It's easier if you post the relevant code, using the code tags in this forum.

Be more clear on your problem, also.
Feb 24 '08 #2

P: 21
It's too huge to be posted here...
Feb 24 '08 #3

Markus
Expert 5K+
P: 6,050
It's too huge to be posted here...
If so, why do you think people will take the time to look through such a huge zip when you give such a limited question?
Feb 24 '08 #4

ronverdonk
Expert 2.5K+
P: 4,258
You should be able to show some code, i.e. the form (if there is one) with the 'pg' named field in it, or the url processing code, and the code processing the 'pg'.

And do not forget to show that code within the appropriate code tags!

Ronald
Feb 24 '08 #5

P: 21
Extra server load ? That file was hosted on my own site ...
any way .. my website , the one which i'm having prolems with is at http://triway.x10hosting.com/ so you can ckeck it out if you want ...
"The Files"(Complete Listing)
---------
index.php
[PHP]<html>
<head>
<title>
<?php
if($_get[pg])
{
echo "Triway Software - " + $_get[pg];
}
else
{
echo "Triway Software - Homepage";
}
?>
</title>
<link rel="stylesheet" type="text/css" href="<?php require 'php/styleget.php'; ?>">
<script language="JavaScript" type="Text/JavaScript">
<!--
function info()
{
}
-->
</script>
</head>
<body>

<span class="head">
<h1>
<?php
if ($_get[pg]!=0)
{
echo "Triway Software - " + $_get[pg];
}
else
{
echo "Triway Software - Homepage";
}
?>
</h1>
</span>

<span class="bar">
<span class="subhead">NaviBar</span>
<hr />
<?php require "php/navgen.php"; ?>

</span>

<span class="main">
<?php
$errurl=substr_count($_get[pg],".");
$errurl=$errurl+substr_count($_get[pg],"/");
$errurl=$errurl+substr_count($_get[pg],"\\");
if ($errurl>0)
{
echo "Terminal error ! V[".errurl."]";
}
else
{
require "php/contentgen.php";
}
?>

</span>

<span class="foot">
&copy; Aviral Dasgupta 2007<?php require "php/infogen.php"; ?>

</span>

</body>
</html>[/PHP]

php/contentgen.php

[PHP]<?php
$path=$_GET["pg"];
if ($path==0)
{
$path="home";
}

if (file_exists("txt/".strtolower($path)))
{

################# File Content Retrieve ################

require "txt/".$path;

}
else
{
echo "Terminal error ! P[".$path."]";
}
?>[/PHP]

I don't think that the rest of the files deserve listing...
Now the problem that I'm having is that visiting http://triway.x10hosting.com/index.p...&style=default
still shows the homepage...and even if pg is set in the URL , the code doesn't have it ...
Feb 26 '08 #6

Markus
Expert 5K+
P: 6,050
Wrap your array indeces in single quotes
and capitalise get
[php]
$_GET['something'];
[/php]
Feb 26 '08 #7

P: 21
It's still not working... even with the $_get["pg"]s changed to $_GET['PG'].Please ... I really need help.
Feb 26 '08 #8

Markus
Expert 5K+
P: 6,050
It's still not working... even with the $_get["pg"]s changed to $_GET['PG'].Please ... I really need help.
The 'PG' doesn't need to be capitalised.
Feb 26 '08 #9

harshmaul
Expert 100+
P: 490
Heres the problem what i found.

You are comparing the get value with a number, any string casted to a number returns 0.

So the path is getting set to home.

You need to do something like this......

[PHP]if (IsSet($_GET['pg'])){
//The rest of code goes here
}[/PHP]

Hode that helped!
Feb 26 '08 #10

P: 21
Thanks ! That did it ! ( That was a hard-to-find-error and I didn't know that "XXX"!=0)
Mar 4 '08 #11

Post your reply

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