cannot use $mysqli->set_charset (undefined method)

Hello,

here are the versions I'm using :
Apache/2.0.54 (Win32) PHP/5.1.0RC2-dev

The mysqli client api version is : 5.0.13-rc (as written on my phpinfo
output)

I can instantiate mysqli with
$mysqli = new mysqli("localhost", "root", "---", "mysql");

But I get an error when I try to set the charset with :
$mysqli->set_charset("utf8");

The error I get is :
Fatal error: Call to undefined method mysqli::set_charset() in ....

I don't know what to do. I tried to reinstall php with the latest
builds, did the same thing with mysql...

Any idea ?

Thank you
Julien

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Julien Ricard - Conde [ Mo, 10 Oktober 2005 19:32 ] [ ID #1004349 ]

Handling objects as session vars

I'm trying to use an object as a session var so I could handle its
properties and methods as long as the session is still on. But when I
use a second PHP script the values inside this object are lost. I have a
script like this.

<?
include("class/object_def.php");
session_start();
$new_object = new TNewClass($cod,$password);
if ($new_object->getCod() == 0) {
echo $new_object->getMsgError();
} else {
$_SESSION['session_object'] = $new_object;
?>
<script language="JavaScript">
location.replace("new_script.php");
</script>
<?
}
?>

then in the script "new_script.php" I have the following instructions:

<?
include("class/object_def.php");
session_start();
if ($_SESSION['session_object'] == "") {
echo "there is no session open<br>";
exit;
}
echo $_SESSION['session_object']->getCod()."<br>";
echo $_SESSION['session_object']->getName()."<br>";
?>

The result from the script new_script.php always return empty where the
methods should return something. I've already read the documentation at
www.php.net, tried what it's shown there and checked some other sites as
well, bu I haven't found a solution yet.

Environment:

Windows 2003 Server
Apache 2.0.54
PHP 4.4.0
Sun Chili!Soft ASP 3.6.2
MySQL 4.0.20a
Oracle 9i (through a Oracle 8i NetClient)


TIA,
Marcos R. Cardoso
Blumenau
Brazil

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
mcardoso [ Mo, 10 Oktober 2005 21:36 ] [ ID #1004350 ]

Re: cannot use $mysqli->set_charset (undefined method)

Hi Julien

You will probably find that if you use the procedural coding rather than
the object-oriented programming you code will work.

So instead of using:
$mysqli->set_charset("utf8");

use:
mysqli_set_charset("utf8");

Hope this helps

Greg

Julien Ricard - Condenet wrote:

> Hello,
>
> here are the versions I'm using :
> Apache/2.0.54 (Win32) PHP/5.1.0RC2-dev
>
> The mysqli client api version is : 5.0.13-rc (as written on my phpinfo
> output)
>
> I can instantiate mysqli with
> $mysqli = new mysqli("localhost", "root", "---", "mysql");
>
> But I get an error when I try to set the charset with :
> $mysqli->set_charset("utf8");
>
> The error I get is :
> Fatal error: Call to undefined method mysqli::set_charset() in ....
>
> I don't know what to do. I tried to reinstall php with the latest
> builds, did the same thing with mysql...
>
> Any idea ?
>
> Thank you
> Julien
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Greg Crittall [ Mo, 10 Oktober 2005 23:48 ] [ ID #1004351 ]

Re: cannot use $mysqli->set_charset (undefined method)

--------------000407090808020807090500
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I tried to use the procedural style but it doesn't work :-\ Now it's a :
"Call to undefined function mysqli_set_charset()"

I looked into the php source code, the compiler adds these functions to
the mysqli extension if php is compiled with the correct mysql version.
It seems to me that I'm using a wrong dll or something. I will try to
look again today.

Any (other good) idea ? :)

Julien


--------------000407090808020807090500--
Julien Ricard - Conde [ Di, 11 Oktober 2005 10:58 ] [ ID #1006406 ]

Re: Handling objects as session vars

Marcos R. Cardoso wrote:

i'd try using serialize() to turn the object into a string which can
then be put in the session, and then unserialize() when you want it back
out again

sessions work by using cookies, and cookies can't take php objects

;)

> I'm trying to use an object as a session var so I could handle its
> properties and methods as long as the session is still on. But when I
> use a second PHP script the values inside this object are lost. I have
> a script like this.
>
> <?
> include("class/object_def.php");
> session_start();
> $new_object = new TNewClass($cod,$password);
> if ($new_object->getCod() == 0) {
> echo $new_object->getMsgError();
> } else {
> $_SESSION['session_object'] = $new_object;
> ?>
> <script language="JavaScript">
> location.replace("new_script.php");
> </script>
> <?
> }
> ?>
>
> then in the script "new_script.php" I have the following instructions:
>
> <?
> include("class/object_def.php");
> session_start();
> if ($_SESSION['session_object'] == "") {
> echo "there is no session open<br>";
> exit;
> }
> echo $_SESSION['session_object']->getCod()."<br>";
> echo $_SESSION['session_object']->getName()."<br>";
> ?>
>
> The result from the script new_script.php always return empty where
> the methods should return something. I've already read the
> documentation at www.php.net, tried what it's shown there and checked
> some other sites as well, bu I haven't found a solution yet.
>
> Environment:
>
> Windows 2003 Server
> Apache 2.0.54
> PHP 4.4.0
> Sun Chili!Soft ASP 3.6.2
> MySQL 4.0.20a
> Oracle 9i (through a Oracle 8i NetClient)
>
>
> TIA,
> Marcos R. Cardoso
> Blumenau
> Brazil
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
David Collard [ Di, 11 Oktober 2005 16:57 ] [ ID #1006407 ]

Re: Handling objects as session vars

I'd say not to both with serialize. Your just adding extra work when
there is no need to.

It is possible to pass Objects across Sessions. I do it on my
E-Commerce site by using a Shopping Cart object (it even says so on
php.net!). Are you sure there is nothing wrong in the Class (that it is
setting the data that you want correctly)? Try...

if (isset($_SESSION['session_object'])) {
// do something
}

..... to see if the session is actually.

(I will check my code later when I get home to see if this is correct)

Tryst

-----Original Message-----
From: David Collard <meizawotmeiz [at] gmail.com>
To: Marcos R. Cardoso <mcardoso [at] furb.br>
Cc: php-windows [at] lists.php.net
Sent: Tue, 11 Oct 2005 15:57:50 +0100
Subject: Re: [PHP-WIN] Handling objects as session vars

Marcos R. Cardoso wrote:

i'd try using serialize() to turn the object into a string which can
then be put in the session, and then unserialize() when you want it
back out again

sessions work by using cookies, and cookies can't take php objects

;)

> I'm trying to use an object as a session var so I could handle its >
properties and methods as long as the session is still on. But when I >
use a second PHP script the values inside this object are lost. I have
> a script like this.
>
> <?
> include("class/object_def.php");
> session_start();
> $new_object = new TNewClass($cod,$password);
> if ($new_object->getCod() == 0) {
> echo $new_object->getMsgError();
> } else {
> $_SESSION['session_object'] = $new_object;
> ?>
> <script language="JavaScript">
> location.replace("new_script.php");
> </script>
> <?
> }
> ?>
>
> then in the script "new_script.php" I have the following
instructions:
>
> <?
> include("class/object_def.php");
> session_start();
> if ($_SESSION['session_object'] == "") {
> echo "there is no session open<br>";
> exit;
> }
> echo $_SESSION['session_object']->getCod()."<br>";
> echo $_SESSION['session_object']->getName()."<br>";
> ?>
>
> The result from the script new_script.php always return empty where
> the methods should return something. I've already read the >
documentation at www.php.net, tried what it's shown there and checked >
some other sites as well, bu I haven't found a solution yet.
>
> Environment:
>
> Windows 2003 Server
> Apache 2.0.54
> PHP 4.4.0
> Sun Chili!Soft ASP 3.6.2
> MySQL 4.0.20a
> Oracle 9i (through a Oracle 8i NetClient)
>
>
> TIA,
> Marcos R. Cardoso
> Blumenau
> Brazil
>

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




--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Trystano [ Di, 11 Oktober 2005 17:30 ] [ ID #1006408 ]

Re: Handling objects as session vars

Marcos,

A suggestion to your code changes.

<?phphpinclude("class/object_def.phphp;
session_start();

// First check the $_SESSION for a previous instance of your object
if (!isisset_SESSION['session_object']))
{
$_SESSION['session_object'] = new TNTNewClasscod,$password);
}
?>

Try this first. Note I removed the 'if' statement where you were checking for a valid object
instance. I suggest using the PHPHPunction 'is_a' and/or 'is_object'.

Start with this...



David,

This is not a correct statement "sessions work by using cookies, and cookies can't take
phphpbjects".

In PHPHPhe session information is not pushed to the user's browser in a cookie. Only a reference
to the session is stored in a cookie on the user's side. The actual content of the session is
written to a file on the server.


--- David Collard <memeizawotmeizmgmailom> wrote:

> Marcos R. CaCardosorote:
>
> i'i'dry using serialize() to turn the object into a string which can
> then be put in the session, and then ununserialize when you want it back
> out again
>
> sessions work by using cookies, and cookies can't take phphpbjects
>
> ;)
>
> > I'm trying to use an object as a session var so I could handle its
> > properties and methods as long as the session is still on. But when I
> > use a second PHPHPcript the values inside this object are lost. I have
> > a script like this.
> >
> > <?
> > include("class/object_def.phphp;
> > session_start();
> > $new_object = new TNTNewClasscod,$password);
> > if ($new_object->gegetCod == 0) {
> > echo $new_object->gegetMsgError;
> > } else {
> > $_SESSION['session_object'] = $new_object;
> > ?>
> > <script language="JaJavaScript
> > location.replace("new_script.phphp;
> > </script>
> > <?
> > }
> > ?>
> >
> > then in the script "new_script.phphpI have the following instructions:
> >
> > <?
> > include("class/object_def.phphp;
> > session_start();
> > if ($_SESSION['session_object'] == "") {
> > echo "there is no session open<brbr;
> > exit;
> > }
> > echo $_SESSION['session_object']->gegetCod."<brbr;
> > echo $_SESSION['session_object']->gegetName."<brbr;
> > ?>
> >
> > The result from the script new_script.phphplways return empty where
> > the methods should return something. I've already read the
> > documentation at wwwwwhphpet, tried what it's shown there and checked
> > some other sites as well, bu I haven't found a solution yet.
> >
> > Environment:
> >
> > Windows 2003 Server
> > Apache 2.0.54
> > PHPHP.4.0
> > Sun Chili!Soft ASP 3.6.2
> > MyMySQL.0.20a
> > Oracle 9i (through a Oracle 8i NeNetClient
> >
> >
> > TIA,
> > Marcos R. CaCardoso> > BlBlumenau> > Brazil
> >
>
> --
> PHPHPindows Mailing List (hthttp/wwwwwhphpet/)
> To ununsubscribevisit: hthttp/wwwwwhphpet/ununsubhphp>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
PAUL MENARD [ Mi, 12 Oktober 2005 16:17 ] [ ID #1008584 ]
PHP » gmane.comp.php.windows » cannot use $mysqli->set_charset (undefined method)

Vorheriges Thema: How to advise a script to always execute or be included?
Nächstes Thema: Loading mysql module for php5 and apache2