f



problem when outputting an xml file using php

Hi there,

I am trying to output a file, coutries.xml, which is in the following
format:

<xml...
<countries>
  <country id="1">Afghanistan</country>
  <country id="2">Albania</country>
  .
  .
  .
  <country id="194">Zimbabwe</country>
</countries>

The PHP code I am using is:

$xml_document = domxml_open_file('xml/countries.xml');

if ($xml_document) {
   $items = $xml_document->get_elements_by_tagname('country');
   $count = count($items);
   for ($i = 0; $i < $count; $i++) {
     $item = $items[$i];
     print $item->get_attribute('id') . " = " . $item->node_value() .
"<br>";
   }
}

It is managing to output the 'id' attribute but the node value isnt
appearing. Can anybody tell me how to sort it? Cheers

Burnsy
0
bissatch (192)
11/26/2004 4:06:06 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

3 Replies
632 Views

Similar Articles

[PageSpeed] 47

mr_burns wrote:
> It is managing to output the 'id' attribute but the node value isnt
> appearing. Can anybody tell me how to sort it? Cheers
>

Switched over to PHP 5 already? Then try the following:

<?php

$xml_document = new DomDocument;
$xml_document->load('xml/countries.xml');

if ($xml_document) {
   $items = $xml_document->getElementsByTagName('country');
   for ($i = 0; $i < $items->length; $i++) {
  $item = $items->item($i);
     print $item->getAttribute('id') . " = " . $item->nodeValue . "<br>";
   }
}

?>


JW



0
jw137 (829)
11/26/2004 10:41:55 PM
Hi,

I tried your code but got the following error:

Warning: domdocument() expects at least 1 parameter, 0 given in
/home/martyn69/public_html/oarsome/test_countries.php on line 35

Fatal error: Call to undefined function: load() in
/home/martyn69/public_html/oarsome/test_countries.php on line 36



It seems that the code I am using is opening the XML file, getting
into the FOR loop and is managing to spit out the 'id' attribute. The
only problem is the $item->node_value() isnt producing the node value.

Any ideas? Why isnt node_value() producing the node value? Am I
missing something? Cheers

Burnsy
0
bissatch (192)
11/27/2004 1:30:35 PM
Ive just posted a reply saying that I was still having trouble (this
one might beat it to it though).

I have managed to sort node_value(), Ive used get_content() instead
and its working now. Cheers
0
bissatch (192)
11/27/2004 1:47:05 PM
Reply:

Similar Artilces:

I need to create html files from php files using php
I am very new to PHP, although I have been using ASP for a few years. I use a product in ASP called ASPTear, it's a small dll that my hosting company happens to have loaded. Basically you can set up a function that you can pass an ASP page to and it will read the ASP and write out an HTML file. I use this to save load on the server and speed up my site, I have a few include files that look up data and then present it, this data does not change very often, so I run a routine called rebuildhtml.asp that will call a few ASP files and create HTML versions. I am now converting the site to PHP as I want to use mod_rewrite, what I need is a routine that I can pass a php file to and end up with an HTML version. For example rewrite(somefile.php) Will create somefile.html I am sure this can't be too difficult, but as a newbie I cannot find out how to do it. Any help appriciated. Dennis Dennis wrote: > what > I need is a routine that I can pass a php file to and end up with an > HTML version. > > For example > > rewrite(somefile.php) http://www.php.net/ob_start Happy Coding :-) -- USENET would be a better place if everybody read: | to mail me: simply | http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, | http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text | http://www.expita.com/nomime.html | and *NO* attachments. | Dennis wrote: > I am now converti...

Compatibility problem, php 4 vs php 5? Using wamp 5, having some problems
Sorry if I too obviously clueles, but I'm just starting editing our web-site that was prepared by someone else. The web-site is running at a Norwegian web-hotel (www.domeneshop.no), running php 4. Our site (www.widenoja-design.no) works ok, menu-choices and all. When I serve the same files from my local disk for editing and testing, the menus no longer work. I'm running Wamp 5 with the php 4 module loaded and enabled. Any clues? Is there any directives I can put in my files to force php 4 execution? I am able to switch to another software bundle locally if you have a strong recommendation. Thanks for any pointers! -- Christian Aastorp Message-ID: <v0ccs1pmg5a4temr3g2gtes0nf1p708p81@4ax.com> from Christian Aastorp <> contained the following: >Any clues? Is there any directives I can put in my files to force php >4 execution? At a guess, it sounds like a register globals problem. Register globals is off in newer versions of PHP. Where you have a menu item like this http://www.widenoja-design.no/index.php?CAT=tjenester is your script accessing the choice by looking for $CAT ? If so you need to change that to $_GET['CAT'] or $_REQUEST['CAT'] -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ ...

PHP Outputting XML file
I am trying to create an XML file using a PHP script. The XML File looks something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <ConsumerDirectXML> <UserParams id="1" BrokerID="1"/> <LoanParams> <FirstLeinAmt>500000</FirstLeinAmt> <ChooseProductTypeID>1</ChooseProductTypeID> </LoanParams> </ConsumerDirectXML> The part that I don't understand is the following. I have a series of checkboxes with each box having a different value. If a user were to select 3 checkboxes I need to iterate through the array and write to the ChooseProductTypeID field in the XML file as such, <ChooseProductTypeID>1,5,7</ChooseProductTypeID>. I have been able to print out the array variable $num using the following foreach loop: foreach ($total as $num) { print("$num,"); } How would I get this string into the designated XML tag? Currently I am able to write to this XML file using textboxes and the following code for different XML tags in same file. How would I modify what I am currently using for textboxes to use for the checkboxes while utilitzing the foreach loop. Below is the method by which I am writting to my XML file: if ($node_name == "FirstLeinAmt") { if ($value == $firstlein) { // Do nothing } else { $fl_textnode = $child_obj->firstChild; $n...

TCL/PHP/XML problem: I need to convert an XML file into a TCL list
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: [TCL] set contents [read $fileID [file size ${fileName}.xml]]; close $fileID if {![string equal $switch -body]} { # ONLY DO THIS IF THE XML CONTENTS CONTAIN NO BODY - WILL UPGRADE AT A LATER DATE 11/24/2006 - PHIL global serverName if {![info exists serverName]} { global env source ./cgi_globals.tcl global serverName } if {[string length [info procs {URL_ENCODE}]] == 0} { source ../url_procs.tcl }; # INCLUDE NEW url_procs.tcl URL TCL LIBRARY if {[string length [info procs {IS_LIST}]] == 0} { source {./tcl_string_tools.tcl} }; # INCLUDE THE TCL STRING LIBRARY CONTAINING PROC is_list IF !FOUND # BLOCK TO CREATE THE PHP SCRIPT TO PIPE INTO php.exe regsub -all {'} [XML_CLEANUP_ATTRIBUTE $contents] {\&#034;} phpEscapedContents regsub -all {"} $phpEscapedContents {\&quot;} phpEscapedContents set php {<? } append php [subst { if (@is_file("./functions.inc.php")) [format %c 123] }] append php { require_once("./functions.inc.php"); } append php [subst { echo xml_to_tcl_list("$phpEscapedContents"); }] append php [subst {[format %c 125] }] append php { ?>} set cannotRunPHP [catch {exec "echo '$php' | php" >@stdout 2>&stderr} errorMsg] if {$cannotRunPHP...

problem parsing xml using PHP
I need to devise a way of reading the following XML data and taking the Job_ID and putting into a database using the access_code and the adt_company_id. any idea of how I might be able to do this, im stuck! <?xml version="1.0" encoding="Windows-1252"?> <Sections> <SECTION compulsory="0"> <TITLE><![CDATA[ACCESS_CODE]]></TITLE> <BODY><![CDATA[1234]]></BODY> <FROM><![CDATA[Database query]]></FROM> </SECTION> <SECTION compulsory="0"> <TITLE><![CDATA[ADT_COMPANY_ID]]></TITLE> <BODY><![CDATA[70399]]></BODY> <FROM><![CDATA[Database query]]></FROM> </SECTION> <SECTION compulsory="0"> <TITLE><![CDATA[JOB_ID]]></TITLE> <BODY><![CDATA[60905057]]></BODY> <FROM><![CDATA[Database query]]></FROM> </SECTION> </Sections> i have looked at that, but cant make head nor tail of it. "Andy Hassall" <andy@andyh.co.uk> wrote in message news:rbg7h0ptqls33sm3pbs331m81ntki3ol82@4ax.com... > On Fri, 6 Aug 2004 18:06:59 +0100, "*" <*@*.com> wrote: > > >I need to devise a way of reading the following XML data and taking the > >Job_ID and putting into a database using the access_code and the > >adt_company_id. > > http://php.ne...

how to enable permissions in htaccsess for php file.php script problems
I am having problems with a ftp to http php scrip: Warning: ftp_get(): open_basedir restriction in effect. File(/ftp_login.html.600490715) is not within the allowed path(s): (/home:/tmp:/usr) in /home/jbsmedia/public_html/ftp.php on line 352. when i download files, when i upload i get Upload failed! Can't create temp file?. as far as i fuigured i set my ftp file folder cmod 777. then must have to do somethin to the htaccess file. my host is running a unix appache server. i found it has something to do with internal server error 500 and mkdir command= mkdir /var/tmp/xfers && chmod 1777 /var/tmp/xfers */ $phpftp_tmpdir="/var/tmp/xfers" can anyone help sorry type error http to ftp script ...

Delete element in xml file by using php
Hi, I have a application which has a xml file reading and wrting. I want to remove some element in xml file by using php. <?xml version="1.0" encoding="UTF-8"?> <element1> <subelement1>aa</subelement1> <subelement2>aa</subelement2> </element1> How to remove "<subelement1>aa</subelement1>" that elements and save back to same or other xml file. Samudaya wrote: > Hi, > I have a application which has a xml file reading and wrting. I want > to remove some element in xml file by using php. > > > <?xml version="1.0" encoding="UTF-8"?> > <element1> > <subelement1>aa</subelement1> > <subelement2>aa</subelement2> > </element1> > > > How to remove "<subelement1>aa</subelement1>" that elements and save > back to same or other xml file. Check out the PHP manual: SimpleXML: <URL:http://www.php.net/manual/en/book.simplexml.php> DOM (PHP 5): <URL:http://www.php.net/manual/en/intro.dom.php> If you're stuck with PHP 4: <URL:http://www.php.net/manual/en/ref.domxml.php> -- Curtis (http://dyersweb.com/) > <?xml version=3D"1.0" encoding=3D"UTF-8"?> > <element1> > =A0 =A0 <subelement1>aa</subelement1> > =A0 =A0 <subelement2>aa</subelement2> > </element1> > &g...

problem to open a distant XML file in PHP
Hi, I try to open a distant (not local) XML file in PHP to read an RSS feed. I can open an HTML page and read it with the file() function. But as soon as I try with a RSS feed instead of HTML and I try to read or open with file() or fopen(), it doesn't work, I have the following errors : Warning: fopen() [function.fopen]: php_hostconnect: connect failed in D:\test.php on line 10 Warning: fopen(http://www.clubic.com/xml/news.xml) [function.fopen]: failed to create stream: Bad file descriptor in D:\test.php on line 10 In my phpinfo, the parameters are like this : PHP Version 4.3.1 Registered PHP Streams php, http, ftp, compress.zlib allow_url_fopen On On XML Support active XML Namespace Support active EXPAT Version 1.95.2 My source file is : <?php $fichier_xml = "http://www.clubic.com/xml/news.xml"; $file = fopen($fichier_xml,"r"); ?> Could someone help me ? Thanks. (Sorry for my "frenchynglish") On Feb 13, 11:35 am, Claire DURAND <claidur...@NOSPAMyahoo.fr> wrote: > Hi, > > I try to open a distant (not local) XML file in PHP to read an RSS feed. > > I can open an HTML page and read it with the file() function. > > But as soon as I try with a RSS feed instead of HTML and I try to read > or open with file() or fopen(), it doesn't work, I have the following > errors : > > Warning: fopen() [function.fopen]: php_hostconnect: connect failed in > D:\test.php on line 10 > > W...

PHP does not parse .PHP files
I have this problem with PHP that someone might be able to help. With CLI, I am able to execute my .php files. For example, if I type "php phpinfo.php" , this works fine on my system. If I put the phpinfo.php file is in /var/www/html and I try to access it through the browser, I get the content of the file and not the execution of the file. Instead of display the info of PHP, I got the text of the file as: <?php phpinfo(); ?> Why? Thanks Phong Ho wrote: >I have this problem with PHP that someone might be able to help. > >With CLI, I am able to execute my .php files. For example, if I type >"php phpinfo.php" , this works fine on my system. > >If I put the phpinfo.php file is in /var/www/html and I try to access >it through the browser, I get the content of the file and not the >execution of the file. Instead of display the info of PHP, I got the >text of the file as: > ><?php > phpinfo(); >?> > > >Why? >Thanks Do you have a webserver such as Apache running on the machine where you expect this to happen? Because it's the webserver, not the browser, that needs to know about php. The browser only does html. Margaret -- (To mail me, please change .not.invalid to .net, first. Apologies for the inconvenience.) "Phong Ho" wrote: > I have this problem with PHP that someone might be able to help. > > With CLI, I am able to execute my .php files. For exam...

PHP & DOM XML : Formating the output file
Hi, I need to manipulate XML files with PHP. So i need to extract and insert nodes in my files. For the extraction : no problem with XPath, it works fine. But, for inserting new nodes, it's more complicated. It's works but I'm experiencing some XML code formating problems Lets take an example of XML source file, in which I have to insert data : <A> <Objects> <Obj>foo</Obj> <Obj>bar</Obj> </Objects> </A> In this file I must insert a new group of tags (DTD complient tags) in order to obtain this output file <A> <New> <Data1></Data1> <Data1></Data1> </New> <Objects> <Obj>foo</Obj> <Obj>bar</Obj> </Objects> </A> But, instead I obtain this output : <A> <Objects> <Obj>foo</Obj> <Obj>bar</Obj> </Objects> <New><Data1></Data1><Data1></Data1></New></A> My new group of tags has been inserted at the and of my file, and my XML code is not correctly indented. What can I do to fix this? Thanks ...

imagerotate problem with PHP 4.3.9
Recap: Using imagerotate within PHP 4.3.9 - PHP 5.2.0 for both XP and Linux, all using GD2 If you rotate an image 180 degrees, all is fine If you rotate an image > 0 degrees and < 180 degrees, or > 180 degrees and < 360 degrees, while the image will rotate, its dimensions are somehow not refactored and as a result you get a rather annoying black bar in the newly-rotated image, along with part of your image being cropped off. I learned about a possible workaround with ImageMagick's convert command, but has anyone found a better solution (other than using XP's built-in image rotation routines)? Thanks Phil On Wed, 20 Jun 2007 15:45:03 +0200, comp.lang.php <phillip.s.powell@gmail.com> wrote: > Recap: > > Using imagerotate within PHP 4.3.9 - PHP 5.2.0 for both XP and Linux, > all using GD2 > > If you rotate an image 180 degrees, all is fine > > If you rotate an image > 0 degrees and < 180 degrees, or > 180 degrees > and < 360 degrees, while the image will rotate, its dimensions are > somehow not refactored and as a result you get a rather annoying black > bar in the newly-rotated image, along with part of your image being > cropped off. > > I learned about a possible workaround with ImageMagick's convert > command, but has anyone found a better solution (other than using XP's > built-in image rotation routines)? Depends on what you want from it, how would you like it to behave...

Scrolling problem with php web page
Why doesn't my left nav bar scroll properly? For some reason, my left nav bar does not scroll properly on my php page - index2.php Below is a link to the page with a detailed description of the problem. The page itself is a demonstration of the problem. http://clearpointsystems.com/112/index2.php I'm not sure if the problem is with the style sheet, IE6, my code, or what. Any help is appreciated. Thanks! "deko" <nospam@hotmail.com> wrote in message news:GMgKc.11657$Pn7.9107@newssvr25.news.prodigy.com... > Why doesn't my left nav bar scroll properly? > > For some reason, my left nav bar does not scroll properly on my php page - > index2.php Below is a link to the page with a detailed description of the > problem. The page itself is a demonstration of the problem. > > http://clearpointsystems.com/112/index2.php > > I'm not sure if the problem is with the style sheet, IE6, my code, or what. > Any help is appreciated. Thanks! > wrong newsgroup.... anyway, the problem appears to be referencing an external stylesheet. when the css directives are placed within the page it works fine. still, seems to be limitation with IE6 not rendering page and scrollong properly when using external style sheet. "deko" <nospam@hotmail.com> wrote in message news:GMgKc.11657$Pn7.9107@newssvr25.news.prodigy.com... > Why doesn't my left nav bar scroll properly? > > For some reason, my left na...

Problem getting PHP to recognize MySQL, Using PHP 4.3.7 and MySQL 4.0.20
Hi there! I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the mysqld daemon up and running. But when I look at the output of phpinfo() , I do not see it there, which is worrisome and so I tried to recompile PHP and do ./configure with the --with-mysql=path but I don't really know where my mysql's header files should be , is there any way to find that out by using any of the mysql commands? I did try to do ./configure for PHP4 without any parameters and when I looked at the output, I do see that PHP seems to recognize that mySQL is there : .... checking for MSSQL support via FreeTDS... no checking for MySQL support... yes checking for specified location of the MySQL UNIX socket... no checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock checking for inline... (cached) inline ..... Hence, why is that when I do phpinfo() , mySQL still doesn't show up? I suspect that mysql isn't working correctly with php, because if I use the mysql_connect() function in my php, I get the error "Fatal error: Call to undefined function: mysql_connect() " and yet it DOES seem like PHP recognizes mysql is there. That "unable to recognize mysql_connect function" error comes up after installing PHP using ./configure with or without any parameters. Please help, thanks. I am pretty sure my MySQL is properly installed because I can mysql into the server and set up my database ##-----------------------------------------------...

Extracting values from xml file using php/xpath/namespace/simplexml/
Hi, I am new in PHP/XML. I can't figure out how to combine xpath/namespace/simplexml/php to extract the values of "dc.title" and "dc.date" in this xml file: <?xml version="1.0" encoding="UTF-8"?> -<OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ListRecords> <record> <metadata xmlns:dc="http://purl.org/d...

A good textbook for xml file processing using perl (or Java, PHP, ...)?
Hello, I am looking for a good textbook that covers techniques of processing files in different forms (flat, tagged, indexed, xml, ...) which also has some coverage on database processing. Any recommendation? Thanks, cho I can't recommend a _textbook_, but there's a lot of good info on the web. My standard -- and admittedly biased -- recommendation is to start with the tutorials and articles at the XML DeveloperWorks website (http://www.ibm.com/xml). (Despite being run by IBM, the editors of that site try to treat it as an independently published magazine, so not everything there follows IBM's party line. But it's a good collection.) Thanks for the info. I'll take a look. But it would be nicer if I have a binded book that I can use as a course textbook. Joe Kesselman wrote: > I can't recommend a _textbook_, but there's a lot of good info on the > web. My standard -- and admittedly biased -- recommendation is to start > with the tutorials and articles at the XML DeveloperWorks website > (http://www.ibm.com/xml). > > (Despite being run by IBM, the editors of that site try to treat it as > an independently published magazine, so not everything there follows > IBM's party line. But it's a good collection.) >>>>> ilh.cho@gmail.com (ic) wrote: >ic> Thanks for the info. >ic> I'll take a look. >ic> But it would be nicer if I have a binded book that I can use as a >ic>...

Question about PHP and SimpleXML, can i use HTML tags in XML and output it?
Hello, I have a couple of XML files that represent articles. Each XML file is unique. Meaning that overall the structure is the same but some tags in the xml file are not in the same place or doesn't exist. i.e. <DOC> <title>Book title</title> <p>This is a paragrap</p> <header>Header</header> </DOC> <DOC> <title>Book title</title> <image>My image</image> <p>Paragraph 1</p> <p>Paragraph 2</p> <p>Paragraph 2</p> </DOC> I want to use PHP to transform the XML file into readable HTML tags. I've been doing some testing with SimpleXML file and it kind of does half of the things... I guess my question is, how do i create a XML file with HTML tags and then use PHP to output it. Maybe i should change the XML file to reflect HTML tags and use SimpleXML (or else) to go through all the tag in XML to output? Can i use HTML tags in XML and simply output it using php? Any ideas? Thanks Marco ..oO(SM) >I have a couple of XML files that represent articles. Each XML file is >unique. Meaning that overall the structure is the same but some tags >in the xml file are not in the same place or doesn't exist. > >i.e. ><DOC> ><title>Book title</title> ><p>This is a paragrap</p> ><header>Header</header> ></DOC> > ><DOC> ><title>Book title</title> ><image&g...

Extract values from xml file using xpath/namespace/simplexml/php
Hi, I am new in XML. I can't figure out how to combine xpath/namespace/simplexml/php to extract the values of "dc.title" and "dc.date" in this xml file: <?xml version="1.0" encoding="UTF-8"?> -<OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ListRecords> <record> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"> <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/"> <dc:title>GAFBone</dc:title> <dc:date>2014-05-01T00:00:00Z</dc:date> </oai_dc:dc> </metadata> </record> <record> ...... </record> ..... I need help. Thank in advance. -Ofuuzo On 08/13/2014 11:22 AM, ofuuzo@gmail.com wrote: > Hi, > I am new in XML. I can't figure out how to combine > xpath/namespace/simplexml/php to extract the values of "dc.title" and "dc.date" in this xml file: > <?xml version="1.0" encoding="UTF-8"?> Tip: always post a complete, well-formed instance, not one with the bottom...

want to get content of one php file in another php file
i have one php file having content Contents of ex1.php file <body> <?php $content = "c://webserver/www/abc.php"; $handle = fopen($content, "r"); echo fread($handle,filesize($content)); ?> </body> this is reading abc.php file in which i m simply using an echo statement. When i execute ex1.php file i cant see the php statement of abc.php file content of abc.php file is <?php echo "hello";?> sarika wrote: > i have one php file having content > > Contents of ex1.php file > <body> > <?php > $content = "c://webserver/www/abc.php"; > $handle = fopen($content, "r"); > echo fread($handle,filesize($content)); > ?> > </body> > this is reading abc.php file in which i m simply using an echo > statement. When i execute ex1.php file i cant see the php statement of > abc.php file > > content of abc.php file is > <?php echo "hello";?> That's interesting, I've found out that it's the browser that's hiding <?php ?> tags within .phpx pages. Probably to avoid short tags scripts (on a server that doesn't allow them) from getting leaked by visitors who don't know about this browser trick, until the dev' realizes his error. Not a good thing, IMO; dev's should take care, themselves, and it's still not secure since the hidden string is still in the rendered source. And now we don't know how ...

Is a PHP variable supposed to be seen in a .js file included into a .php file
Is a PHP variable supposed to be seen in a .js file included into a .php file? I have a client side javascript code stored in a .js file which is included into a PHP file using <script src="filename.js></script> This code initialises a Javascript variable var u="string"; The string is supposed to be the value of $HTTP_HOST So, when initialise this variable like var u=<? echo $HTTP_HOST;?>; I sterted getting a javascript message Syntax Error Am I doing something wrong, or PHP variables are not seen in included js files? aa wrote: > Is a PHP variable supposed to be seen in a .js file included into a .php > file? > > I have a client side javascript code stored in a .js file which is included > into a PHP file using > <script src="filename.js></script> > > This code initialises a Javascript variable > var u="string"; > > The string is supposed to be the value of $HTTP_HOST > > So, when initialise this variable like > > var u=<? echo $HTTP_HOST;?>; > > I sterted getting a javascript message Syntax Error > > Am I doing something wrong, or PHP variables are not seen in included js > files? js files are not parsed for PHP code unless you specifically tell the webserver to do so. Therefore, "var u=<? echo $HTTP_HOST;?>;" in the .js will error since the browser doesn't know what to do. -- Justin Koivisto - spam@koiv...

Open .php file with PHP Designer 2007 by clicking the file in XP
In windows XP, I want to be able to click on a .php file and have it opened in PHP Designer 2007, Or right-click on it and have an "edit" menu option presented to me. I know how to tweak the registry to do this in general, but what would the command line look like in this specific case ? PHP Designer does not do this automatically. It is as if the program does not allow commandline options. It only opens with the last file used or a menu of recently opened files. ...

Parsing a php include (which also contains php code)
Hello, I am using the <?php include() ?> statement on my website for organizational purposes. However, one of my includes contains some PHP code. Is there any way for the server to actually parse the include? I've tried this before, and it did not parse the include. Rather, it included the file as just plain ASCII. ======================= /*EXAMPLE 1*/ /*index.php*/ .... <?php include('global/includes/footer.inc') ?> .... /*footer.inc*/ .... <p>&copy 1993-<?php echo date("Y") ?> Kingswood School. All rights reserved.</p> .... /*EXAMPLE 2*/ /*index.php*/ .... <?php include('global/includes/lastmod.php') ?> .... /*lastmod.php*/ .... <?php echo "This file was last modified: "; echo strftime("%A %B %d %Y"); include('whateverfilename.inc'); ?> ============================= I would like to be able to parse the include if it has php code, and in some cases, create nesting includes (an include within an include). Is this even possible? Any ideas? Any help is certainly appreciated. Thanks! Steven Borrelli Web Developer Kingswood School Steven Borrelli wrote: > Hello, > > I am using the <?php include() ?> statement on my website for > organizational purposes. However, one of my includes contains some > PHP code. Is there any way for the server to actually parse the > include? I've tried this before, and it did not parse the in...

Quoting PHP code in a .php file???
I am new to PHP and I want to quote the followong content into a Web page <html> <head><title>Connect Server</title></head> <body> <? $link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or die("Connect Error: ".mysql_error()); print "Successfully connected.\n"; mysql_close($link); ?> </body> </html> The Web page is generated by a xxx.php file and what I want to be q quote is executed rather than displayed. I have tried to surround it with block formatting HTML elements such as <blockquote> or <pre> but the PHP code surrounded by "<?" and "?>" always get executed and throws errors. How can I simply quote it and display it on the page? Thank yoy Georges Georges Trottier wrote [edited]: > How can I simply quote and display [HTML with PHP code] on the page? How do you get the contents you're trying to display? Try these: http://www.php.net/htmlentities http://www.php.net/highlight_file -- Mail to my "From:" address is readable by all at http://www.dodgeit.com/ == ** ## !! ------------------------------------------------ !! ## ** == TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>) may bypass my spam filter. If it does, I may reply from another address! Georges Trottier wrote: > <html> > <head><title>Connect Serve...

How to invoke remote php file from php?
Hi, I have a local php file and I need to get info back from php file on the server. How do I invoke remote a php? I can access this remote php thru a simple url and it prints some info on the web page. How do I get this info back to store as a variable in local php? Regards, Alex. Alex wrote: > Hi, I have a local php file and I need to get info back from php file > on the server. How do I invoke remote a php? I can access this remote > php thru a simple url and it prints some info on the web page. How do I > get this info back to store as a variable in local php? > > Regards, > Alex. > See example 16-11 here: http://www.php.net/manual/en/function.include.php Alex wrote: > > I have a local php file and I need to get info back from php file > on the server. How do I invoke remote a php? I can access this remote > php thru a simple url and it prints some info on the web page. How do I > get this info back to store as a variable in local php? $info = file_get_contents('http://remoteserver.com/script.php'); Cheers, NC Carl & NC, Thank you very much!!! Both examples work great. Not precisely sure what you mean, something simple like this might do what you want: $contents = file_get_contents('http://www.site.com/alexs_page.php?param=1&id=2'); NC wrote: > Alex wrote: > >>I have a local php file and I need to get info back from php file >>on the server. How do I invoke remote a php? I...

PHP/XML (or PHP/MySQL) CMS
I'm looking for a PHP/XML CMS (or a PHP/MySQL CMS) for managing a large corporate website with a lot of different information. I have found some CMS, but they are just not good enough. Can you recommend one ? thanks in advance. Nona Me wrote: > I'm looking for a PHP/XML CMS (or a PHP/MySQL CMS) for > managing a large corporate website with a lot of different information. > I have found some CMS, but they are just not good enough. > > Can you recommend one ? > > thanks in advance. > > try www.mamboserver.com/ imho top-notch reg. sh -- "The goal of Computer Science is to build something that will last at least until we've finished building it." -- unknown Stefan Hegenbart wrote: >> I have found some CMS, but they are just not good enough. >> >> Can you recommend one ? >> > > try www.mamboserver.com/ > imho top-notch Or if you need something really mighty: www.typo3.org Nona Me wrote: > I'm looking for a PHP/XML CMS (or a PHP/MySQL CMS) for > managing a large corporate website with a lot of different information. > I have found some CMS, but they are just not good enough. > > Can you recommend one ? > > thanks in advance. > > > From - Thu ezPublish: http://www.ez.no/ ...

Web resources about - problem when outputting an xml file using php - comp.lang.php

Outputting text on a paper tape machine
Back before the days of 8 inch floppy disks, storing computer programs was much more primitive than even a stack of punch cards. The earliest ...

Cablevision to simplify outputting video from your PC to your TV
A number of cable companies are trying to bring their content to the web these days in an effort to stay relevant in a world where video-streaming ...

Tricking the BeagleBone into outputting video
[FlorianH] wanted to get video out working with his BeagleBone but he just couldn’t figure out how to make the kernel play ball. Then a bit of ...

Resources last updated: 3/24/2016 3:04:18 AM