Hello,
I am learning PHP5. I need to parse XML file and I found a solution in some
book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others).
Unfortunately I have two problems that I don't understand:
Warning: Call-time pass-by-reference has been deprecated; If you would like
to pass it by reference, modify the declaration of xml_set_object( ). If you
would like to enable call-time pass-by-reference, you can set
allow_call_time _pass_reference to true in your INI file.
in /home/robert/public_html/rozgloszenia/bookparse.php on line 20
Parse error: syntax error, unexpected ';', expecting T_FUNCTION
in /home/robert/public_html/rozgloszenia/bookparse.php on line 100
<html>
<head>
<title>Moja biblioteczka</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
class BookList
{
var $parser;
var $record;
var $current_field = '';
var $field_type;
var $ends_record;
var $records;
function BookList($filen ame)
{
$this->parser = xml_parser_crea te();
xml_set_object( $this->parser, &$this); // HERE PROBLEM
xml_set_element _handler($this->parser, 'start_element' , 'end_element');
xml_set_charact er_data_handler ($this->parser, 'cdata');
$this->field_type = array('title' =1,
'author' =2,
'isbn' =1,
'comment' =1);
$this->ends_record = array('book' =true);
$x = join("", file($filename) );
xml_parse($this->parser, $x);
xml_parser_free ($this->parser);
}
function start_element($ p, $element, &$attributes )
{
$element = strtolower($ele ment);
if ($this->field_type[$element] != 0)
{
$this->current_fiel d = $element;
}
else
{
$this->current_fiel d = '';
}
}
function end_element($p, $element)
{
$element = strtolower($ele ment);
if ($this->ends_record[$element])
{
$this->records[] = $this->record;
$this->record = array();
}
$this->current_fiel d = '';
}
function cdata($p, $text)
{
if ($this->field_type[$this->current_fiel d] === 2)
{
$this->record[$this->current_fiel d][] = $text;
}
elseif ($this->field_type[$this->current_fiel d] === 1)
{
$this->record[$this->current_fiel d] .= $text;
}
}
function show_menu()
{
echo "<table border=1>\n";
foreach ($this->records as $book)
{
echo "<tr>";
$authors = join(', ', $book['author']);
printf("<th><a href='%s'>%s</a></th><td>%s</td></tr>\n",
$_SERVER['PHP_SELF'] . '?isbn=' . $book['isbn'],
$book['title'],
$authors);
echo "</tr>\n";
}
function show_book($isbn )
{
foreach ($this->records as $book)
{
if ($book['isbn'] !== $isbn)
{
continue;
}
$authors = join(', ', $book['author']);
printf("<b>%s</bautor: %s.<br>", $book['title'], $authors);
printf("ISBN: %s<br>", $book['isbn']);
printf("Komenta rz: %s<p>\n", $book['comment']);
}
?>
Powrót do <a href="<?= $SERVER['PHP_SELF'] ?>">listy książek</a>.<p>
<?
}
}; // HERE PROBLEM
$my_library = new BookList("books .xml");
if ($_GET['isbn'])
{
$my_library->show_book($_GE T['isbn']);
}
else
{
$my_library->show_menu();
}
</body>
</html>
Could you help me plase?
Thanks a lot!
/RAM/ 2 2862 r_********@pocz ta.onet.pl wrote:
Hello,
I am learning PHP5. I need to parse XML file and I found a solution in some
book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others).
Unfortunately I have two problems that I don't understand:
Warning: Call-time pass-by-reference has been deprecated; If you would like
to pass it by reference, modify the declaration of xml_set_object( ). If you
would like to enable call-time pass-by-reference, you can set
allow_call_time _pass_reference to true in your INI file.
in /home/robert/public_html/rozgloszenia/bookparse.php on line 20
Parse error: syntax error, unexpected ';', expecting T_FUNCTION
in /home/robert/public_html/rozgloszenia/bookparse.php on line 100
xml_set_object( $this->parser, &$this); // HERE PROBLEM
Yup, just use xml_set_object( $this->parser, $this);, the reference to
the second parameter rather then the value should be declared in the
funcion.
}; // HERE PROBLEM
Braces ({}) for constructs like clasess, functions, and control
structures should bever end with ;
--
Rik Wasmus
....spamrun finished r_********@pocz ta.onet.pl wrote:
Hello,
I am learning PHP5. I need to parse XML file and I found a solution in
some book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others).
Unfortunately I have two problems that I don't understand:
Warning: Call-time pass-by-reference has been deprecated;
It means that this is wrong:
<?php
function foo($bar) { ... }
foo(&$baaz);
?>
And this is right:
<?php
function foo(&$bar) { ... }
foo($baaz);
?>
Parse error: syntax error, unexpected ';', expecting T_FUNCTION
in /home/robert/public_html/rozgloszenia/bookparse.php on line 100
That means that you missed a "}" in the show_menu() function, check it out.
I'd suggest you to use an editor capable of keeping track of nested
parenthesis.
Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
La palabra es libre; la acción, muda; la obediencia, ciega.- J. Schiller This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ¤ Alias |
last post by:
I have a function named
getID3info (lvwDiscInfo.SelectedItem).
What is the difference between
getID3info (lvwDiscInfo.SelectedItem)
and
Call getID3info(lvwDiscInfo.SelectedItem) ?
|
by: William Morris |
last post by:
So, what's the prevailing opinion regarding the use of the "CALL" keyword?
I'm working with a third-party ASP application, adapting for our system, and
the CALL keyword is used everywhere. I've never used it, preferring instead
to just type the procedure name and parameters so:
myProcedure parm1, parm2
Any thoughts on
call...
|
by: Simon Wigzell |
last post by:
What is the call? Better yet is there a link to a page that describes all
the possible javascript calls to the various browser menu items and explains
compatibility across different browsers? Thanks!
|
by: John |
last post by:
Hi all, is there a way to call "Select Users or Groups" dialog from .NET?
This is the dialog when you browse the users or groups on local computer or
on Windows domain. Please advice. Thanks.
|
by: balg |
last post by:
An ActiveX control has a call to "UserControl.Parent" which
fails when it is interopped and added to a .Net Form.
Is there any way to access to .Net parent control/it's interfaces
from VB6 ActiveX Control.
Thanks,
BalG
| |
by: Larry Menard |
last post by:
Test code:
$dbconn = odbc_connect($dbname, $username, $password);
$path = "C:\Temp\myJar.jar";
$statement = "CALL SQLJ.INSTALL_JAR('file://$path', 'myJarId')";
$result = odbc_exec($dbconn, $statement);
Result:
PHP Warning: odbc_exec(): SQL error: CLI0119E Unexpected system failure.
|
by: a |
last post by:
Hi everybody,
My config: Win XP (or 2003), Apache 2.0.54, PHP 5.1.2.
I have been trying to handle the case of a lenghty opearation on the server
while providing the user with feedback and ability to cancel, and nothing
seems to work so far.
The following code is one attempt to address this, and it is called as
result of a POST:
|
by: Thorsten Ottosen |
last post by:
Hi,
I'm trying to escape html before its saved in a database.
I tried
$text = htmlentities( $reader->value );
but that don't work for e.g. japanese characters.
|
by: javelin |
last post by:
I'm studying "Visual Basic Developer's Guid to ASP & IIS", and I am
following instructions an pp 72-75. I am creating a WebClass, and enter
code as instructed, and it all is entered correctly.
When I try and run, I get the folowing error:
"The call to Server.CreateObject failed while checking permissions.
Access is denied to this...
|
by: Frederick Gotham |
last post by:
If we have a simple class such as follows:
#include <string>
struct MyStruct {
std::string member;
MyStruct(unsigned const i)
{
|
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...
| |
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...
|
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. ...
|
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...
|
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...
|
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...
|
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.
| |