HI all,
Weird problem....
in the file queries.inc.php I've this:
$query = 'select * from list where content = '.$idcontent;
I've this code in my page:
$idcontent = 15;
require_once("q ueries.inc.php" );
The query fails: when I do echo the query I've:
select * from list where content =
The $idcontent isn't set in the include...why ? how to fix it ? 9 1748
On May 10, 4:33 pm, "Bob Bedford" <b...@bedford.c omwrote:
HI all,
Weird problem....
in the file queries.inc.php I've this:
$query = 'select * from list where content = '.$idcontent;
I've this code in my page:
$idcontent = 15;
require_once("q ueries.inc.php" );
The query fails: when I do echo the query I've:
select * from list where content =
The $idcontent isn't set in the include...why ? how to fix it ?
actually use an include_once (rather than require)
On May 10, 4:33 pm, "Bob Bedford" <b...@bedford.c omwrote:
HI all,
Weird problem....
in the file queries.inc.php I've this:
$query = 'select * from list where content = '.$idcontent;
I've this code in my page:
$idcontent = 15;
require_once("q ueries.inc.php" );
The query fails: when I do echo the query I've:
select * from list where content =
The $idcontent isn't set in the include...why ? how to fix it ?
Sounds like the var $idcontent is actually null rather than it being
an include problem. Try echoing that var on the include page and
running it on its own
Ciarán
Sounds like the var $idcontent is actually null rather than it being
an include problem. Try echoing that var on the include page and
running it on its own
Ciarán
Sorry- my mistake I didnt notice you've defined the var in the page
itself. I do this exact thing on a bunch of pages and it works fine. I
use a require_once just like you too. Are you running an old version
of PHP or something maybe?
sorry i know I'm not being much help but it all looks good to me!
Sorry- my mistake I didnt notice you've defined the var in the page
itself. I do this exact thing on a bunch of pages and it works fine. I
use a require_once just like you too. Are you running an old version
of PHP or something maybe?
Thanks for your reply. I use PHP 4.4.1
"David Gillen" <Be****@RedBric k.DCU.IEa écrit dans le message de news: sl************* ******@murphy.r edbrick.dcu.ie...
Bob Bedford said:
>HI all, Weird problem....
in the file queries.inc.php I've this: $query = 'select * from list where content = '.$idcontent;
I've this code in my page: $idcontent = 15; require_once(" queries.inc.php ");
The query fails: when I do echo the query I've:
select * from list where content =
The $idcontent isn't set in the include...why ? how to fix it ?
Is your $query = .. line inside of function in teh queries.inc.php ?
If so $idcontent is out of scope.
NO it's not....
I've also tried to define the idcontent var as global again in the
queries.inc.php but it doesn't work either.
If you define a variable $x and then INCLUDE a file such as
include_once("p ath"); it should work.
So if you have:
$query = 'select * from list where content = '.$idcontent;
And
$idcontent = 15;
require_once("q ueries.inc.php" );
You need to change require to include.
so it should be
$idcontent = 15;
include_once("q ueries.inc.php" );
And you can check this by doing something like
if ( $idcontent 0 ) {
}
On May 10, 2:59 pm, SterLo <sterling.hamil ...@gmail.comwr ote:
If you define a variable $x and then INCLUDE a file such as
include_once("p ath"); it should work.
So if you have:
$query = 'select * from list where content = '.$idcontent;
And
$idcontent = 15;
require_once("q ueries.inc.php" );
You need to change require to include.
so it should be
$idcontent = 15;
include_once("q ueries.inc.php" );
And you can check this by doing something like
if ( $idcontent 0 ) {
}
Not true -- require and include behave identically in every way except
for what happens when the file cannot be included for some reason.
<http://www.php.net/require>
Bob Bedford kirjoitti:
HI all,
Weird problem....
in the file queries.inc.php I've this:
$query = 'select * from list where content = '.$idcontent;
I've this code in my page:
$idcontent = 15;
require_once("q ueries.inc.php" );
The query fails: when I do echo the query I've:
select * from list where content =
The $idcontent isn't set in the include...why ? how to fix it ?
Just as a sanity test:
<?php
$foo ='bar';
require_once('e cho.php');
?>
echo.php:
<?php echo $foo; ?>
Does the simplest possible test case like the one above work? If it
works, then the problem is not in including, but somewhere else. If it
doesn't, the latest version of php 4 is 4.4.7, you should upgrade to
that if there indeed is a problem related to passing variables to
included pages, which I highly doubt.
-- Ra*********@gma il.com
"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Bob Bedford wrote:
HI all,
Weird problem....
in the file queries.inc.php I've this:
$query = 'select * from list where content = '.$idcontent;
I've this code in my page:
$idcontent = 15;
require_once("q ueries.inc.php" );
The query fails: when I do echo the query I've:
select * from list where content =
The $idcontent isn't set in the include...why ? how to fix it ?
Hi Bob,
away from all prior given replies I strongly suggest you to review your
programming style. Use a less a possible global variables in your code.
Don't be anger with me, I just want to give you food for thought.
hth,
Roy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mark |
last post by:
IF I have something like this:
<title><?php print($pagetitle); ?></title>
<body>
<?php include("folders/my_include.php"); ?>
</body>
</html>
and my_include.php contains the value to the variable ($pagetitle). How do I
get the value before the code for the <title> is written. This is just a
|
by: John Aspinall |
last post by:
Hi,
Ive got a navigation bar for my web pages in an include (top_nav.asp).
On my homepage (index.asp) and all the other site pages I have a
reference to this include which includes my navigation bar in each
page.
<!--#include virtual="/includes/nav/top_nav.asp"-->
|
by: mark |
last post by:
How does one call a variable defined in a class defined in file1.cpp
from another file file2.cpp. Or can one call a class from a different
file ?
(Besides the standard way to define the variable in a header file and
include this header file where required)
|
by: Mike |
last post by:
I'm new to PHP - moving over from ASP.
I have a number of include files, the first of which sets the value of
a variable $loginmsg. I use that variable in a subsequent include
file, but get a "Notice: Undefined variable loginmsg" warning. I've
had a good look at previous posts concerning this warning, and see that
isset() is recommended to prevent this kind of warning. Is this
totally necessary?
In ASP, and include file becomes...
|
by: chellappa |
last post by:
hi Everybody !
decalaring variable in a.h and using that vaaariable in a1.c and
inalization is in main.c it is possible .........pleaase correct that
error
is it Possible? i am trying it gives error!
In file included from main.c:2:
a1.c:3: error: initializer element is not constant
| |
by: GGawaran |
last post by:
First off, Hi everyone new to .asp and am trying to self teach myself. Im trying to figure out what exactly im doing wrong, or maybe what I think I can do, I really cant.
The Idea.
-------------------
On our website, we have several pieces of code we entered in so in the event that when you click on the category section, and "Engraving" was selected, it would load an include file and show our engraving options, etc. Well, I figured, we...
|
by: Justcallmedrago |
last post by:
How would you declare and assign a variable inside a function THAT HAS
THE NAME OF A PARAMETER YOU PASSED
example:
when you call createvariable("myvariable")
it will declare the variable "myvariable"
and then maybe assign it something.
myvariable = "this is a real variable"
|
by: j.woodcock |
last post by:
is there a way of having a file that's name is a variable (eg
dependant on the user name) act like a include.
i know that you cant define the file for an include asp tag using a
variable and that reading the file using "Response.Write
FSO.OpenTextFile(ppp, 1, False, False).readall" prints the file, and
treating it like a html file. can anyone suggest another way of doing
this?
|
by: leonardodiserpierodavinci |
last post by:
Hi. Sorry for what is perhaps a neophyte question: is it possible to
pass a variable to a PHP script from inside another PHP piece of code?
For instance, the file test.php (which of course resides on a
webserver that supports PHP) is as such:
<?php
echo("<i>the variable abc contains " . $_GET . "</i>");
?>
|
by: atwiawomo |
last post by:
Hi
This may be simple to solve, but I can't seem to do it :(
I am trying to generate an include name on an image gallery page from
a variable name.
By this I mean I already have a numeric value set the variable
$imageCat.
What I want to do is pull in an external include file using the
|
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...
| |
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |