php-general Digest 6 Jul 2008 22:05:40 -0000 Issue 5554

Topics (messages 276330 through 276337):

Re: class_is_loadable?
        276330 by: Fabrice VIGNALS

Re: Creating XML files
        276331 by: Fabrice VIGNALS

Re: No Database Connection possible (mySQL)
        276332 by: Fabrice VIGNALS

Re: URL Rewrite
        276333 by: Fabrice VIGNALS

Re: Session variables disappear (some of them only)
        276334 by: Fabrice VIGNALS
        276335 by: tedd

Re: odbc msaccess php5 [Giving Up]
        276336 by: Peter Jackson

Multiple words str_shuffle
        276337 by: Ron Piggott

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 ---
Hi,

The problem is not the autoload but the implementation of such function.
class_is_loadable mean, "hey php look at my class somewhere in my files". PHP should inspect some files, in some directories and list classes.
Which files, which extensions files, in which directories ? ...
In my mind you must replan your autoload, for exemple make a link beetween classes and files name, ie : if file_exists( A.class.php ) include_once( B.class.php) else include_once( A.class.php ); Check the factory method at Zend site, that explain how to work with class method, without to know the exact name of class (ex : load an specific class depending of the database available)



"Larry Garfield" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED]
Greetings, all.

I am trying to figure out a way to implement the following logic, but I am not
sure if it is possible to do so without a lot of additional side work:

I have a class, A, and another class B that extends A. They live in separate
files.  The logic I need to implement is as follows:

if (class_exists('B')) {
 $foo = new B();
}
else {
 $foo = new A();
}

That is all well and good if both A and B are already loaded and parsed, but I
am using spl_autoload to lazy-load classes as needed.  That means the
class_exists() call will return false if B exists but hasn't been included
yet.  What I would like to happen is for PHP to include B if it exists or
give a non-fatal error if it doesn't so that I can instantiate A instead.

Ideally, the logic would be something like the following:

try {
 $foo = new B();  // Try to autoload B, throw exception if it can't.
}
catch (ClassDoesntExistEvenAfterRunningThroughAutoloadException $e) {
 $foo = new A(); // May autoload A at this point, too.
}
// do stuff with $foo

However, as far as I am aware $foo = new B(); will cause a fatal exception if
autoload doesn't find a B.

Does anyone know of a way to achieve the above effect? This is specifically
for PHP 5.2 and later.  Thanks.

--
Larry Garfield
[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
Not so hard to find : http://php.net/manual/en/book.xml.php



"It flance" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED]
Hi all,

Some months ago i worked with XML. And i remember that i was able to create xml files quite easily. Now i don`t have the book i used by the time. I made many searches in google and i don't find something interesting. So i'm wondering if somebody can give a good link with examples. If i remeber well, i can create axml file without writing the hole file to a string before writing the string to the file.

Thanks a lot






--- End Message ---
--- Begin Message ---
First problem : there are not return in the function as it said
Second problem : php make a real connection with a unique id to a server database

$server1 = array("localhost","user","pass")
$server2 = array("localhost2","user2","pass2")

Function mysqlConnectServer($server)
{
$uid = mysql_connect($server) or die(mysql_error());
return $uid;
}

$uidServer1 = mysqlConnectServer( $server1);
$uidServer2 = mysqlConnectServer( $server2);

$db1_1 = mysql_select_db("tava", $uidServer1);
$db1_2 = mysql_select_db("tava2", $uidServer1);
$db2_1 = mysql_select_db("tava", $uidServer2);
$db2_2 = mysql_select_db("tava2", $uidServer2);

In this exemple we used, only 2 mysql connections to create 4 databases connections, on 2 mysql servers.

Depending of your application, you must manage server and database connection, to manage error and problem connection, but also for performance and don't create a server connection each time you connect to a different database on the same mysql server.
Also look at PDO:mysql and mysqli on php.net
Mysqli is simple to use, for exemple mysqli_connect(), use a mysql_connect or a mysql_pconnect depending of your configuration. Also mysqli check all server connection, if already exist it dont create a new connection to the server, but use an allready connection even your code isn't really optimised. PDO is more complex and, in my mind, have some problem of performance at this time.



""Aviation Coding"" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED]
Hi all,

I am having problems with a connection to a mysql database.

I am using

----
function con()
{
mysql_connect("localhost","user","pass") or die(mysql_error());
mysql_select_db("tava") or die(mysql_error());
}
----

Now, when I call the _function_ (!)
----
con() or die("no con");
----
I get the "no con" output.

When I call the mysql_connect and mysql_select directly before executing a
query, I get some DB output. But that won't work when I am using the
function...

Any ideas would be greatly appreciated.

Cheers!

Chris



--- End Message ---
--- Begin Message ---
Look at http://framework.zend.com/manual/en/zend.controller.router.html
Apache configuration et framework methods to rout your files are there.


"Subhranil" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED]

Hi All,

I want to show one URL at browser and content of different URL.

Like user can see the URL at address bar like http://localhost/test/home/
or http://localhost/test/tech/php/        but content of page will be
http://localhost/test/index.php
The URL of the address bar will never change to
http://localhost/test/index.php

Still a  newbie!

Thanks,
Subhranild.

--
View this message in context: http://www.nabble.com/URL-Rewrite-tp18233803p18233803.html
Sent from the PHP - General mailing list archive at Nabble.com.



--- End Message ---
--- Begin Message ---
Difficult to help you because there are many method of session :
- where do you store the sessions_variables : in local file, db or cookie ?
- how you transmit the session id, beetween pages(runtimes) : cookie, $GET link, database ?


Did you check the availability of user cookie if you use it ?
Because if in each page of your application you define a session variable it's sure it will be every time here. But the problem of session it's to transmit its ID between different pages, or session will be reset. If a user don't authorised cookie you must transmit the session id by db storage or $Get link.

Also I don't see, a php modification during the last upgrades to explain that's kind of session problem.




"karma" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED]

Hi !

I have a very weird issue since the last Apache upgrade (-> 2.2.8-r3, a month ago), but I'm not sure it is related (well, I'm pretty sure it's not).

Like many people, I've written an application that use PHP session variables, like $_SESSION["my_variable"].

Sometimes (it doesn't happen all the time), _some_ of these variables are not written in the session file and they are lost after a simple header("Location:...); (same domain). The session file is in the right directory (permissions are fine), but some of my variables are missing.

The facts :
- Apache 2.2.9 + PHP 5.2.6_rc4 running on a Gentoo (up-to-date)
- all my scripts begin with session_start(). I've tried to add session_write_close() before every header(Location:...) call, it doesn't help. - I didn't change anything in my program (it has been running just fine for 2 years), it just began to fail from time to time (I would say 10 times a day). There is no hidden unset() function : it would fail for everyone. - these variables are all set correctly, and they don't have reserved names. - only a few variables disappear, but they are always the same ones (could it depend on their position in the session file ?!?)
- the session files are very small (max 100ko)
- it seems that it doesn't depend on the browser, but IE6 and IE7 seem to be the most affected ones (it may be because my users mostly use these browsers). - I can't reproduce this issue from my local network (any OS/browser - it would be too easy :) - reverting to the previous stable Apache and/or PHP versions doesn't help.
- I didn't change any php.ini directive.

Any idea ?

Thanks !


PS: if you need more details, just ask. The only thing I can't do is pasting the code : the scripts are quite huge.


--- End Message ---
--- Begin Message ---
At 1:48 PM +0200 7/6/08, Fabrice VIGNALS wrote:
Difficult to help you because there are many method of session :
- where do you store the sessions_variables : in local file, db or cookie ?
- how you transmit the session id, beetween pages(runtimes) : cookie, $GET link, database ?


Did you check the availability of user cookie if you use it ?
Because if in each page of your application you define a session variable it's sure it will be every time here. But the problem of session it's to transmit its ID between different pages, or session will be reset. If a user don't authorised cookie you must transmit the session id by db storage or $Get link.

Also I don't see, a php modification during the last upgrades to explain that's kind of session problem.




"karma" <[EMAIL PROTECTED]> a écrit dans le message de news:[EMAIL PROTECTED]

Hi !

I have a very weird issue since the last Apache upgrade (-> 2.2.8-r3, a month ago), but I'm not sure it is related (well, I'm pretty sure it's not).

Like many people, I've written an application that use PHP session variables, like $_SESSION["my_variable"].

Sometimes (it doesn't happen all the time), _some_ of these variables are not written in the session file and they are lost after a simple header("Location:...); (same domain). The session file is in the right directory (permissions are fine), but some of my variables are missing.

The facts :
- Apache 2.2.9 + PHP 5.2.6_rc4 running on a Gentoo (up-to-date)
- all my scripts begin with session_start(). I've tried to add session_write_close() before every header(Location:...) call, it doesn't help. - I didn't change anything in my program (it has been running just fine for 2 years), it just began to fail from time to time (I would say 10 times a day). There is no hidden unset() function : it would fail for everyone.
- these variables are all set correctly, and they don't have reserved names.
- only a few variables disappear, but they are always the same ones (could it depend on their position in the session file ?!?)
- the session files are very small (max 100ko)
- it seems that it doesn't depend on the browser, but IE6 and IE7 seem to be the most affected ones (it may be because my users mostly use these browsers). - I can't reproduce this issue from my local network (any OS/browser - it would be too easy :)
- reverting to the previous stable Apache and/or PHP versions doesn't help.
- I didn't change any php.ini directive.

Any idea ?

Thanks !

If it's any comfort, I had a similar problem sending session variables from a script in a httpdocs directory to a script in a httpsdocs. Some of the variables made it and some didn't. It was very confusing. The client had php 4.3.1 installed, if that's any help.

I never did find out what the problem was and I finally passed everything via a POST.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Peter Jackson wrote:

well thats it Ive come to the conclusion that its a driver/lib issue. From what I can see mdbtools lib only reads and only does basic select. (eg Select * from table where col =thistext But not tex* % or date. Also looks like the project has died (think the last release was 2004 or so.) Thought I would give odbtp ago but cant get that to make. aargghh I give up.

Bastien Koert wrote:
On Sat, Jul 5, 2008 at 11:04 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:


On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson <[EMAIL PROTECTED]>
wrote:


$conn=odbc_connect("Database","","");  works
$a = "abcd"; (this value exists in db)
$stat = "Select * FROM " . '"Table Name"';
$qry = odbc_exec($conn,$stat);
$res = odbc_result_all($qry) or die("Error: ");

The above works as I expect it to.(Returns 70 rows)

If I now want to add a where clause
$stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" =
 " . $a;  (This works)

Now the place I fall into the abyss.
if I change WHERE clause in $stat to
 " WHERE " . '"Column Name"' LIKE abc*  (or other variations like abc%
"abc%" "abc*" 'abc%' 'abc*')
All I end up with is a blank page or Warning odbc_result_all No tuples
available at this result index.

Also I'm having trouble working out how to use a date in the WHERE clause. I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00
etc
 I realize this is probably more odbc/sql related but after a lot of
goggling and reading I havent found the answer (about 5 days so far)


As the data seems to be text based, you need to quote it

WHERE " . '"Column Name"' LIKE 'abc%'

--

Bastien

Cat, the other other white meat



sorry, missed the access dates...

try mm/dd/yyyy as the format

Unfortunately thats the first thing I thought of. I've tried every variation of quote I could think of. Can anyone tell me how to log what the odbc connection is actually sending/receiving? (as opposed to just echoing the sql statement I 'think' its sending.





--- End Message ---
--- Begin Message ---
I am trying to scramble individual words and/or phrases.

When it is a phrase I would like to keep the letters of each word
together, with a space between each one.  The code I have so far is
below.  I use PHP 4.4.7.  The code below is fine for a single word; it
is phrases that I am now trying to accommodate.


An example:

rise and shine

Desired output:

I S R E  N A D   E H I S N

Thanks for your help, 

Ron



$keyword might be 

$keyword = str_shuffle(strtoupper($keyword));

$buffer = "";

for ($count = 0; ($count < strlen($keyword)); $count++) $buffer .=
$keyword{$count}." ";

$keyword = trim($buffer);

unset($buffer);



--- End Message ---

Reply via email to