php-general Digest 13 Nov 2008 19:50:09 -0000 Issue 5788

Topics (messages 283237 through 283264):

Re: Recursive Static Method
        283237 by: Yeti
        283240 by: Dan
        283259 by: ceo.l-i-e.com

how to implement search on site
        283238 by: Jignesh Thummar
        283239 by: Richard Heyes
        283241 by: Jignesh Thummar
        283242 by: Richard Heyes
        283245 by: Jignesh Thummar
        283250 by: Boyd, Todd M.

Weird pdo-mysql behavior
        283243 by: Thodoris
        283244 by: Martijn Korse
        283247 by: Thodoris
        283249 by: Arno Kuhl
        283260 by: Thodoris
        283261 by: ceo.l-i-e.com

Re: Missing DLLs
        283246 by: David Robley
        283251 by: Boyd, Todd M.

PECL HTTP Extension
        283248 by: Rui Quelhas
        283252 by: Thodoris
        283258 by: ceo.l-i-e.com
        283263 by: Jochem Maas
        283264 by: Rui Quelhas

Weird Syntax Error
        283253 by: Kyle Terry
        283254 by: Stut
        283255 by: Michael Kubler
        283256 by: Edgar da Silva (Fly2k)
        283257 by: Boyd, Todd M.

Re: Recursive Static Method]
        283262 by: Craige Leeder

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Some code would be quite helpful here. But your scenario should not
make any problem.

EXAMPLE:
<?
class foo {
        static function test() {
                static $count;
                $count++;
                echo "Call {$count}<br />";
                include_once('test.php');
        }
}
foo::test();
?>

EXAMPLE (@file: test.php):
<?php
if (class_exists('foo')) {
        foo::test();
}
exit();
?>

OUTPUT:
Call 1<br />Call 2<br />

//A yeti

--- End Message ---
--- Begin Message ---
Craige - In short, yes you can recursively call a static method. The
following code, for example, will work fine:

<?php

myClass::myStaticRecursiveMethod(0);

class myClass
{
public static function myStaticRecursiveMethod($x)
{
print $x++;

if($x < 10)
{
self::myStaticRecursiveMethod($x);
}
}
}

?>


However, you'll probably notice if you try it, that the example above only
calls the test() method twice. This is because it's using include_once, and
thus the code within the included file is only executed once. You'd need to
use include/require (not include_once/require_once) to make execute
repeatedly.

If this isn't your problem, and you're still having trouble, paste us the
code you're using (or a subset of it) and I'll have a look for you. :)

Dan


On Thu, Nov 13, 2008 at 7:52 AM, Yeti <[EMAIL PROTECTED]> wrote:

> Some code would be quite helpful here. But your scenario should not
> make any problem.
>
> EXAMPLE:
> <?
> class foo {
>        static function test() {
>                static $count;
>                $count++;
>                echo "Call {$count}<br />";
>                include_once('test.php');
>        }
> }
> foo::test();
> ?>
>
> EXAMPLE (@file: test.php):
> <?php
> if (class_exists('foo')) {
>        foo::test();
> }
> exit();
> ?>
>
> OUTPUT:
> Call 1<br />Call 2<br />
>
> //A yeti
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Works for me:



$ cat recurses.php ; php -q recurses.php

<?php

class recurses {

        static function factorial ($n) {

                assert(is_int($n));

                if ($n == 0) return 1;

                return $n * self::factorial($n - 1);

        }

}



echo "4! = ", recurses::factorial(4), "\n";

?>

4! = 24

--- End Message ---
--- Begin Message ---
I have site of around 25 pages (pure HTML pages). I want to implement search
functionality? How can I? i want to avoid database. And Apache Lucene, i
dont't want to use it. Does any PHP framework provide search and indexing
functionality (Exception Zend_Lucene)?

Thanks,
Jignesh

--- End Message ---
--- Begin Message ---
> I have site of around 25 pages (pure HTML pages). I want to implement search
> functionality? How can I? i want to avoid database. And Apache Lucene, i
> dont't want to use it. Does any PHP framework provide search and indexing
> functionality (Exception Zend_Lucene)?

Why avoid Zend_Lucene? You realise it doesn't require a database? When
I read about it (I haven't actually ised it, it seemed straight foward
to implement and use.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)

--- End Message ---
--- Begin Message ---
Zend_Lucene require lots of efforts? If i have to use DB? how can i do it?

- Jignesh

On Thu, Nov 13, 2008 at 9:30 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:

> > I have site of around 25 pages (pure HTML pages). I want to implement
> search
> > functionality? How can I? i want to avoid database. And Apache Lucene, i
> > dont't want to use it. Does any PHP framework provide search and indexing
> > functionality (Exception Zend_Lucene)?
>
> Why avoid Zend_Lucene? You realise it doesn't require a database? When
> I read about it (I haven't actually ised it, it seemed straight foward
> to implement and use.
>
> --
> Richard Heyes
>
> HTML5 Graphing for FF, Chrome, Opera and Safari:
> http://www.rgraph.org (Updated November 1st)
>

--- End Message ---
--- Begin Message ---
> Zend_Lucene require lots of efforts?

Well like everything in life to get good results will mean you will
have to put some time in. But by no means an innordinate amount (I
would imagine). If you did then the Zend Framework wouldn't be so
good.

> If i have to use DB? how can i do it?

Zend_Lucene is file based - no database required. Therefore it's more
portable (plus it's all PHP based as I understand it) and has fewer
pre-requisites.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)

--- End Message ---
--- Begin Message ---
Thanks Richard.

I have to try Zend_Lucene.

- Jignesh

On Thu, Nov 13, 2008 at 10:17 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:

> > Zend_Lucene require lots of efforts?
>
> Well like everything in life to get good results will mean you will
> have to put some time in. But by no means an innordinate amount (I
> would imagine). If you did then the Zend Framework wouldn't be so
> good.
>
> > If i have to use DB? how can i do it?
>
> Zend_Lucene is file based - no database required. Therefore it's more
> portable (plus it's all PHP based as I understand it) and has fewer
> pre-requisites.
>
> --
> Richard Heyes
>
> HTML5 Graphing for FF, Chrome, Opera and Safari:
> http://www.rgraph.org (Updated November 1st)
>

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jignesh Thummar [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 13, 2008 6:07 AM
> To: Richard Heyes
> Cc: PHP-General List
> Subject: Re: [PHP] how to implement search on site
> 
> Thanks Richard.
> 
> I have to try Zend_Lucene.
> 
> - Jignesh
> 
> On Thu, Nov 13, 2008 at 10:17 AM, Richard Heyes <[EMAIL PROTECTED]>
> wrote:
> 
> > > Zend_Lucene require lots of efforts?
> >
> > Well like everything in life to get good results will mean you will
> > have to put some time in. But by no means an innordinate amount (I
> > would imagine). If you did then the Zend Framework wouldn't be so
> > good.
> >
> > > If i have to use DB? how can i do it?
> >
> > Zend_Lucene is file based - no database required. Therefore it's
more
> > portable (plus it's all PHP based as I understand it) and has fewer
> > pre-requisites.

If you're mainly worried about indexing public pages, why not implement
a Google custom search? They do all the heavy lifting--you just worry
about maintaining your website. All the same SEO you do for Google will
then apply to your website internally...


Todd Boyd
Web Programmer

--- End Message ---
--- Begin Message ---
Hi list,
I am developing something using PDO and I've noticed something weird that I want to share with you. I am creating a database handler in a script and I pass the handler to many functions I use in order to avoid creating a new connection into the function itself. Although this works in a compiled LAMP I have, this stops working when I use a prepackaged version of another LAMP I have.

If I change the script in the non-working system and make the connection from inside the function using a new handler then everything works like a charm.

Is there a chance that I am using a different configuration in say php.ini that can cause such behavior.

Let me know what you think.

--
Thodoris


--- End Message ---
--- Begin Message ---
What do you mean with 'stops working'?

Also, have you created a test-script that only contains (what you think is)
the core-problem? If so, can you paste it here? And if not, i advise you to
make one, so you can exclude that other factors play a role here.


Thodoris wrote:
> 
> Hi list,
>     I am developing something using PDO and I've noticed something weird 
> that I want to share with you. I am creating a database handler in a 
> script and I pass the handler to many functions I use in order to avoid 
> creating a new connection into the function itself. Although this works 
> in a compiled LAMP I have, this stops working when I use a prepackaged 
> version of another LAMP I have.
> 
> If I change the script in the non-working system and make the connection 
> from inside the function using a new handler then everything works like 
> a charm.
> 
> Is there a chance that I am using a different configuration in say 
> php.ini that can cause such behavior.
> 
> Let me know what you think.
> 
> -- 
> Thodoris
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 


-----
http://devshed.excudo.net http://devshed.excudo.net 
-- 
View this message in context: 
http://www.nabble.com/Weird-pdo-mysql-behavior-tp20478083p20478667.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---

What do you mean with 'stops working'?

Also, have you created a test-script that only contains (what you think is)
the core-problem? If so, can you paste it here? And if not, i advise you to
make one, so you can exclude that other factors play a role here.


Thodoris wrote:
Hi list,
I am developing something using PDO and I've noticed something weird that I want to share with you. I am creating a database handler in a script and I pass the handler to many functions I use in order to avoid creating a new connection into the function itself. Although this works in a compiled LAMP I have, this stops working when I use a prepackaged version of another LAMP I have.

If I change the script in the non-working system and make the connection from inside the function using a new handler then everything works like a charm.

Is there a chance that I am using a different configuration in say php.ini that can cause such behavior.

Let me know what you think.

--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-----
http://devshed.excudo.net http://devshed.excudo.net


Suppose I have two tables Contracts and Clients that are connected using ClientId field.

This is a stripped sample code that doesn't work:

<?php


function getClientFullName($id,$dbh){


   $query = "SELECT * FROM Clients WHERE Id=".$id;

   $sthr = $dbh->query($query);


   $res = $sthr->fetch(PDO::FETCH_ASSOC);


   return $res['Name'];


}


try {

$dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 'root', '', array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,PDO::ATTR_PERSISTENT => true));


   $sql = "SELECT * FROM Contracts";

   $sth = $dbh->query($sql);


   print "<pre>";


   while($res = $sth->fetch(PDO::FETCH_ASSOC)) {

       $name = getClientFullName($res['ClientId'],$dbh);

       print $name."<br>";

   }

} catch (Exception $e) {

   print $e->getMessage();

}

?>

And when I say it doesn't work I mean that that I get:

Call to a member function fetch() on a non-object


When calling:     getClientFullName


BTW try to top post.

--
Thodoris


--- End Message ---
--- Begin Message ---
Suppose I have two tables Contracts and Clients that are connected using 
ClientId field.

This is a stripped sample code that doesn't work:

<?php


function getClientFullName($id,$dbh){


    $query = "SELECT * FROM Clients WHERE Id=".$id;

    $sthr = $dbh->query($query);


    $res = $sthr->fetch(PDO::FETCH_ASSOC);


    return $res['Name'];


}


try {

    $dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 'root', 
'', array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,PDO::ATTR_PERSISTENT 
=> true));


    $sql = "SELECT * FROM Contracts";

    $sth = $dbh->query($sql);


    print "<pre>";


    while($res = $sth->fetch(PDO::FETCH_ASSOC)) {

        $name = getClientFullName($res['ClientId'],$dbh);

        print $name."<br>";

    }

} catch (Exception $e) {

    print $e->getMessage();

}

?>

And when I say it doesn't work I mean that that I get:

Call to a member function fetch() on a non-object


When calling:     getClientFullName


BTW try to top post.

-- 
Thodoris
------------------

Hi Theodoris

First place I'd look is to see if the sql query was successful. 
If it failed you'll get this error.
You can try a simple test

    $sth = $dbh->query($sql);
    if ($sth == FALSE) {
        print "failed";
        exit;
    }

Arno


--- End Message ---
--- Begin Message ---
Hi Theodoris

First place I'd look is to see if the sql query was successful. If it failed you'll get this error.
You can try a simple test

   $sth = $dbh->query($sql);
   if ($sth == FALSE) {
       print "failed";
       exit;
   }

Arno



Thanks for the advice but the script works in one of the other systems (running PHP 5.2.x) as well as in the same system using another apache and a different php that is compiled from source and not installed as an rpm package.

The query itself works very good but the basic problem is that the $dbh handler probably doesn't get into the getClientFullName properly.

If I dump the handler and the $id before calling getClientFullName it seems that their contents are as expected but when this function calls fetch on the handler it fails.

I suspect that either PHP version 5.1.6 has a bug on this (but I could find something similar in bugs.php.net) or my distro's package is compiled like...

--
Thodoris


--- End Message ---
--- Begin Message ---
Perhaps when you try to make the connection you should check the return value 
and use whatever PDO error-checking methods exist to find out what went wrong, 
instead of blindly going forward assuming you have a database connection when 
you don't.



Ditto for any result of ->query()



What you are doing now is akin to turning the key in a car, not listening to 
see if it started, and asking a mechanic on the phone why the gas pedal doesn't 
work...



:-)



--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:

> 
> So, that error message about a missing DLL, when it's really a "sub" DLL
> that is missing...
> 
> Is that something in PHP source that could be fixed to specify WHICH dll
> is really missing?
> 
> Or is that just Windows being stupid?
> 
> Mr. Spock has calculated that a quick hack change to that error message to
> be more specific would save approximately 3,141.59 man-hours per week...
> 
> :-)
> 
> I'm happy to put it in bugs.php.net as a feature request, if it's actually
> IN php, but don't want to waste the resources to mark it as junk if
> there's no way PHP could do that.
> 
> Richard "someday I'll re-learn C and download PHP source and start
> hacking" Lynch

IIRC there is a little windows app called dependcywalker which you can point
at an application and it will tell you what libraries are required to run
that application. Google will find it for you.


Cheers
-- 
David Robley

We now return you to your regularly scheduled flame-throwing
Today is Boomtime, the 25th day of The Aftermath in the YOLD 3174. 


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: David Robley [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 13, 2008 6:10 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Missing DLLs
> 
> [EMAIL PROTECTED] wrote:
> 
> >
> > So, that error message about a missing DLL, when it's really a "sub"
> DLL
> > that is missing...
> >
> > Is that something in PHP source that could be fixed to specify WHICH
> dll
> > is really missing?
> >
> > Or is that just Windows being stupid?
> >
> > Mr. Spock has calculated that a quick hack change to that error
> message to
> > be more specific would save approximately 3,141.59 man-hours per
> week...
> >
> > :-)
> >
> > I'm happy to put it in bugs.php.net as a feature request, if it's
> actually
> > IN php, but don't want to waste the resources to mark it as junk if
> > there's no way PHP could do that.
> >
> > Richard "someday I'll re-learn C and download PHP source and start
> > hacking" Lynch
> 
> IIRC there is a little windows app called dependcywalker which you can
> point
> at an application and it will tell you what libraries are required to
> run
> that application. Google will find it for you.

Holy crap! This program is awesome!

http://www.dependencywalker.com/

Just went and downloaded it at your suggestion, and I am *VERY* pleased
with it just in the first couple minutes I've been playing with it.
Sweet program, and should save me some headaches when I go to install
new software!

;)


Todd Boyd
Web Programmer

--- End Message ---
--- Begin Message ---
Following the previous messages, my situation resumes in something like
this. The Extension must be properly installed because the file appears in
the correct path, so it must be something missing in the apache
configuration file ('httpd.conf') or in the php inicialization file
('php.ini'). Could someone please describe me every step i need to take and
everything i need to change in this files when i'm installing a php
extension for the first time and assuming that the php.ini is actually the
native php inicialization file on Leopard ('php.ini.default'), i think that
maybe a little especific "crash-course" can solve all my problems. Someone
please...
Regards

Rui Quelhas

--- End Message ---
--- Begin Message ---

Following the previous messages, my situation resumes in something like
this. The Extension must be properly installed because the file appears in
the correct path, so it must be something missing in the apache
configuration file ('httpd.conf') or in the php inicialization file
('php.ini'). Could someone please describe me every step i need to take and
everything i need to change in this files when i'm installing a php
extension for the first time and assuming that the php.ini is actually the
native php inicialization file on Leopard ('php.ini.default'), i think that
maybe a little especific "crash-course" can solve all my problems. Someone
please...
Regards

Rui Quelhas


Fisrst of all in order for this to work you need to include the module's dir in the extension dir directive in php.ini. This means that you either need to include

"/usr/lib/php/extensions/no-debug-non-zts-20060613/"


in the extensions dir or just copy the module into your current extensions dir. Not so elegant solution though.

You should put something like that in your php.ini:

extension_dir=".;/usr/lib/php/extensions/no-debug-non-zts-20060613;/usr/lib/php/modules"

Now you should additionally tell php besides where to find the modules (with extension_dir) what modules you need to load so add this in php.ini:
extension=http.so


--
Thodoris


--- End Message ---
--- Begin Message ---
> try the full path like so:

> 

> extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/http.so



Wishful thinking.



For reasons beyond my ken, php.ini ONLY accepts paths relative to your 
extensions_dir setting.



I'd suggest the OP check their Apache and other error_logs for more details 
about WHY the extension is not loading.



--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] schreef:
>> try the full path like so:
>>
>> extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/http.so
> 
> Wishful thinking.
> 
> For reasons beyond my ken, php.ini ONLY accepts paths relative to your 
> extensions_dir setting.

that's funny, because very often I've been stuck in situations where php refused
to deal with the extensions_dir setting ... and I have been forced to stick the
full path in (as per the example) ... might be that I had the extension_dir 
setting set
to nothing some how ... it's all a little above me as well and I find I've 
quickly
forgotten what/why I did something after the problem goes away ... until the 
next time
it happens and the merry-go-round starts again.

> I'd suggest the OP check their Apache and other error_logs for more details 
> about WHY the extension is not loading.

good point. if their lucky they're lucky they'll have bene giving a crib sheet
by their teacher that explains what a log is* ;-) ... and how to tail one.

*it's a tubular object garnered from dead trees, available in all sorts of 
lengths,
easily rotated and generally stored in /var/log

> 


--- End Message ---
--- Begin Message ---
Since i'm not obtaining any kind of response from people o first answered
me. I guess is better to talk through here.
To my first message, Micah Gersten asked me if i've placed the extension
path on 'php.ini' my answer was yes, i've tried to do that but it still
wasn't loading the extension. Jochem Maas advised me to place the complete
path to the extension like this
'extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/http.so',
i've also tried it, again with no success.
In the last response, Thodoris told me to place in the php.ini the line
'extension_dir=".;/usr/lib/php/extensions/no-debug-non-zts-20060613;/usr/lib/php/modules"',
adding again the extension directive 'extension=http.so'. Well, seems like
there is no such path like '/usr/lib/php/modules', for the sound of it, the
closest match i get is '/usr/include/php/ext/' (path with the header files
of each extension) or '/usr/libexec/apache2' (path also with '.so' files
regarding apache modules). Either way, i've changed the unexisting path by
each one of these and again nothing happened. I don't know what else i can
do. Could somebody that has installed PECL extensions successfuly on Leopard
help me? I just need to know what i must do in the inicialization files (php
or apache) just like i was installing my first extension and having the fact
that there is the native Leopard 'php.ini.default' already in place.

Regards

Rui Quelhas

--- End Message ---
--- Begin Message ---
I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or
T_VARIABLE or T_NUM_STRING

$insert = "INSERT INTO release_file_upload (upl_file_name, upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id')";

-- 
Kyle Terry | www.kyleterry.com

--- End Message ---
--- Begin Message ---
On 13 Nov 2008, at 15:28, Kyle Terry wrote:
I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or
T_VARIABLE or T_NUM_STRING

$insert = "INSERT INTO release_file_upload (upl_file_name, upl_file_type, upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id')";

I can't see anything wrong with that line (except that I don't think those variables will interpolate correctly, and you don't seem to be escaping stuff going into your SQL which is, ya know, bad!!). Your problem is probably on the line before, possible several lines before. Post a bit of the surrounding code.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Hi Kyle,
The line looks fine in my text editor (SciTE).
Have you checked the line above it is properly enclosed and ended?

Michael Kubler
*G*rey *P*hoenix *P*roductions <http://www.greyphoenix.biz>



Kyle Terry wrote:
I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or
T_VARIABLE or T_NUM_STRING

$insert = "INSERT INTO release_file_upload (upl_file_name, upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id')";


--- End Message ---
--- Begin Message ---
Try:

$insert = "INSERT INTO release_file_upload (upl_file_name, upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
'{$_SESSION['upload']['type']}', '{$_SESSION['upload']['size']}', now(),
'$username', '$path', '$release_id')";

2008/11/13 Kyle Terry <[EMAIL PROTECTED]>:
> I keep getting this syntax error on the following string...
>
> syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or
> T_VARIABLE or T_NUM_STRING
>
> $insert = "INSERT INTO release_file_upload (upl_file_name, upl_file_type,
> upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
> '$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
> '$username', '$path', '$release_id')";
>
> --
> Kyle Terry | www.kyleterry.com
>



-- 
Abraços
Edgar Ferreira da Silva
Engenheiro de Software
Campinas - SP
(19) 8110-0733

-----
Aprenda PHP, cole códigos, saiba das vagas de empregos:
http://www.manjaphp.com.br

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Edgar da Silva (Fly2k) [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 13, 2008 9:39 AM
> To: Kyle Terry
> Cc: PHP General Mailing List
> Subject: Re: [PHP] Weird Syntax Error
> 
> Try:
> 
> $insert = "INSERT INTO release_file_upload (upl_file_name,
> upl_file_type,
> upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
> ('$filename',
> '{$_SESSION['upload']['type']}', '{$_SESSION['upload']['size']}',
> now(),
> '$username', '$path', '$release_id')";
> 
> 2008/11/13 Kyle Terry <[EMAIL PROTECTED]>:
> > I keep getting this syntax error on the following string...
> >
> > syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING
> or
> > T_VARIABLE or T_NUM_STRING
> >
> > $insert = "INSERT INTO release_file_upload (upl_file_name,
> upl_file_type,
> > upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
> ('$filename',
> > '$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
> > '$username', '$path', '$release_id')";

Yup... I was just about to say--you need to wrap your array references with 
curly braces {}. Otherwise, I believe PHP will look for a primitive variable 
named $_SESSION, not an array whose indices are "upload" and "size".

HTH,


Todd Boyd
Web Programmer

--- End Message ---
--- Begin Message ---

--- Begin Message ---
Hi Guys,

I found the problem. I was using the error suppression operator on my include, and thus I could not see the syntatic error on the page.

Problem Solved,
- Craige

Yeti wrote:
Some code would be quite helpful here. But your scenario should not
make any problem.

EXAMPLE:
<?
class foo {
        static function test() {
                static $count;
                $count++;
                echo "Call {$count}<br />";
                include_once('test.php');
        }
}
foo::test();
?>

EXAMPLE (@file: test.php):
<?php
if (class_exists('foo')) {
        foo::test();
}
exit();
?>

OUTPUT:
Call 1<br />Call 2<br />

//A yeti



--- End Message ---

--- End Message ---

Reply via email to