OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 21 Aug 2005 22:55:16 -0000 Issue 3638

php-general-digest-helplists.php.net
Date: Sun Aug 21 2005 - 17:55:16 CDT


php-general Digest 21 Aug 2005 22:55:16 -0000 Issue 3638

Topics (messages 221037 through 221052):

Re: how to know when a php library is installed
        221037 by: Greg Donald

Looking for CMS advice
        221038 by: Zachary Kessin
        221045 by: Esteamedpw.aol.com

Re: support for database interaction
        221039 by: Greg Donald

Re: Problem between php4.4 and mysql
        221040 by: Alex Scott
        221042 by: Alex Scott
        221046 by: JamesBenson
        221048 by: Alex Scott
        221049 by: Jasper Bryant-Greene
        221052 by: Jasper Bryant-Greene

Need help with for loop, pulling MySQL data, completely lost
        221041 by: Dan Trainor
        221043 by: Evan Priestley
        221050 by: Dan Trainor

Re: PHP and Prolog
        221044 by: Rory Browne
        221047 by: Edin KadibaÅ¡ić

Resizing thumbnails to the browser
        221051 by: Murray . PlanetThoughtful

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On 8/21/05, Lizet Pena de Sola <lizettheniceweb.com> wrote:
> I need to test whether a library is installed with php or not.

extension_loaded();

--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

attached mail follows:


I am about to start on a project that seems like it would be right for a
CMS system. It will be about 80% rather boring stuff with about 20%
custom database work. I have looked at XOOPS and a few others. However I
can not seem to find one rather important thing about XOOPS. I
understand how to use a module that someone else wrote, but I have not
found any documentation on how to build my own blocks or application
components.

I am not yet committed to XOOPS, so if there is different system that
would be better that could work as well

--Zach

attached mail follows:


I would check out Mambo: _http://mamboserver.com_ (http://mamboserver.com)
 
- Clint

attached mail follows:


On 8/21/05, Fernando Garza <ferdrggmail.com> wrote:
> I am creating a 'Shell' in prolog language that interacts with a 'Visual
> Prolog' database format in 'Win32', I would like to interact with this
> database with 'PHP', just like the interaction with 'MySQL' database, can
> you give me some notion or the code that need to be executed to get this
> done? for example in:
>
> 'mysql_connect'
>
> or
>
> 'mysql_create_db'
>
> what code is executed behind this functions?
>
> I think the functions to make this done should be execute a program with
> some function, passes values and receive values from the 'shell'
>
> any idea?

http://pecl.php.net/support.php#tutorials

--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

attached mail follows:


On 21 Aug 2005, at 12:08, Alex Scott wrote:

> Thanks for reply,
>
> But just briefly, why should it have been working for the past
> month o.k?
>
> Kind regards,
>
> Alex.
>
>
> On 21 Aug 2005, at 11:34, Burhan Khalid wrote:
>
>
>> Alex Scott wrote:
>>
>>
>>> Hi there,
>>> I discovered that our website was not working properly today (To
>>> my horror).
>>> Hosted on redhat enterprise 4.
>>> I think that there is a problem with php 4.4 talking to Apache
>>> mysql 4.1
>>> as the php pages which do not talk to the DB are working but
>>> other php pages are working.
>>>
>>>
>>
>> This has been asked before, and answered (even by me).
>>
>> You need http://php.net/mysqli or change your MySQL configuration
>> so that it allows 'old style' passwords.
>>
>> Google for the rest, or STFA :)
>>
>> Regards,
>> Burhan
>>
>>
>
>

attached mail follows:


Also I am using mysql 4.1.12 and mysql Is designed to work with 4.1.13?

Can anybody suggest to me how I might fix this problem please???

Alex.

On 21 Aug 2005, at 12:23, Alex Scott wrote:

>
> On 21 Aug 2005, at 12:08, Alex Scott wrote:
>
>
>> Thanks for reply,
>>
>> But just briefly, why should it have been working for the past
>> month o.k?
>>
>> Kind regards,
>>
>> Alex.
>>
>>
>> On 21 Aug 2005, at 11:34, Burhan Khalid wrote:
>>
>>
>>
>>> Alex Scott wrote:
>>>
>>>
>>>
>>>> Hi there,
>>>> I discovered that our website was not working properly today (To
>>>> my horror).
>>>> Hosted on redhat enterprise 4.
>>>> I think that there is a problem with php 4.4 talking to Apache
>>>> mysql 4.1
>>>> as the php pages which do not talk to the DB are working but
>>>> other php pages are working.
>>>>
>>>>
>>>>
>>>
>>> This has been asked before, and answered (even by me).
>>>
>>> You need http://php.net/mysqli or change your MySQL configuration
>>> so that it allows 'old style' passwords.
>>>
>>> Google for the rest, or STFA :)
>>>
>>> Regards,
>>> Burhan
>>>
>>>
>>>
>>
>>
>>
>
>

attached mail follows:


Sounds like you have a duplicate entry in your httpd.conf for the PHP
module, 100% of the time ive seen that error is the above reason, so I
suggest checking your LoadModule * sections, depending whether you have
a shared libphp4.so module or built-in module there should or shouldnt
be a LoadModule section present.

HTH

Alex Scott wrote:
> Hi there,
>
> I discovered that our website was not working properly today (To my
> horror).
> Hosted on redhat enterprise 4.
>
> I think that there is a problem with php 4.4 talking to Apache mysql 4.1
> as the php pages which do not talk to the DB are working but other php
> pages are working.
>
> I restarted apache using the inetd script as well as mysql using the
> inetd script.
> However the problem exists. I can enter mysql through the shell and
> tables seem intact.
> I have no relevant errors in my log file.
>
> One thing I noticed was that when I went to restart Apache it said (
> before restarting):
> [Sun Aug 21 10:39:08 2005] [warn] module php4_module is already loaded,
> skipping
>
> Should I try to be loading that module, somehow?
>
> Any suggestions in how to get PHP working with mysql again would be
> much appreciated as it is a busy sight, so slightly stressed.
>
> Thanks Alex.

attached mail follows:


On 21 Aug 2005, at 20:47, Alex Scott wrote:

> Thanks,
> Yes I found that it was also loading php.conf from conf.d , so
> moved that up a level restartedd apache and that error ceased.
> However I am still finding that the database connected php pages
> are not loading.
>
> I don't know why they just seemed to have stopped working, phpbb
> forum as well. When I loging I get a message about might have been
> hacked in the ssh window,
> but I don't know if that was just someone trying to login?
>
> Cheers for any more ideas,
>
> Alex.
>
>
> On 21 Aug 2005, at 19:39, JamesBenson wrote:
>
>
>> Sounds like you have a duplicate entry in your httpd.conf for the
>> PHP module, 100% of the time ive seen that error is the above
>> reason, so I suggest checking your LoadModule * sections,
>> depending whether you have a shared libphp4.so module or built-in
>> module there should or shouldnt be a LoadModule section present.
>>
>>
>> HTH
>>
>>
>>
>> Alex Scott wrote:
>>
>>
>>> Hi there,
>>> I discovered that our website was not working properly today (To
>>> my horror).
>>> Hosted on redhat enterprise 4.
>>> I think that there is a problem with php 4.4 talking to Apache
>>> mysql 4.1
>>> as the php pages which do not talk to the DB are working but
>>> other php pages are working.
>>> I restarted apache using the inetd script as well as mysql using
>>> the inetd script.
>>> However the problem exists. I can enter mysql through the shell
>>> and tables seem intact.
>>> I have no relevant errors in my log file.
>>> One thing I noticed was that when I went to restart Apache it
>>> said ( before restarting):
>>> [Sun Aug 21 10:39:08 2005] [warn] module php4_module is already
>>> loaded, skipping
>>> Should I try to be loading that module, somehow?
>>> Any suggestions in how to get PHP working with mysql again would
>>> be much appreciated as it is a busy sight, so slightly stressed.
>>> Thanks Alex.
>>>
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>

attached mail follows:


> On 21 Aug 2005, at 21:24, Jasper Bryant-Greene wrote:
>>
>> As far as your database problem goes... Have you recently installed
>> MySQL 4.1 or has it previously been working with MySQL 4.1?
>>

Alex Scott wrote:
> I Installed it about a month ago (from RPM's) and php 4.4 as well
> the two were working together fine until this morning it would seem.
> Do you have a theory?
>

Well, it's hard to say without a bit more detail. Are you able to give
us the actual error that PHP is giving on the database connected pages?

I assume you are using the mysqli functions rather than the mysql
functions to access your database?

Please remember to send replies to the list, there are other far more
knowledgeable people out there who will be able to help too!

Jasper

attached mail follows:


M. Sokolewicz wrote:
> Jasper Bryant-Greene wrote:
>>
>> Well, it's hard to say without a bit more detail. Are you able to give
>> us the actual error that PHP is giving on the database connected pages?
>>
>> I assume you are using the mysqli functions rather than the mysql
>> functions to access your database?
>
> just in case you didn't know, mysqli wasn't available before PHP 5.0.0.
> The user states to be using PHP 4.4.x
>

Apologies, didn't read his email properly. In that case, do you have
MySQL set up to accept old passwords? The password-hashing function
changed with MySQL 4.1, and the mysql PHP function uses the old function.

>> Please remember to send replies to the list, there are other far more
>> knowledgeable people out there who will be able to help too!

Again, *please* send replies to the list as well, not just me!

Jasper

attached mail follows:


Hello, all -

As a pet project of mine, I've decided to write a bit of code. This is
what I have, and it's not working as expected:

if ($action == "prepareforupdate") {
        unlink("UPDATES/".$id."/9.jpg");
        $query0 = "SELECT * FROM updates WHERE id=".$id."";
        if (!$dbdata = mysql_query($query0)) {
                echo "Can't run query: ".mysql_error();
                die;
        };
        
        for ($i = 9; $i >= 0; $i--) {
                $j = $i - 1;
        
                echo "Getting ready to rename UPDATES/$id/$j.jpg to
                  UPDATES/$id/$i.jpg || &nbsp;&nbsp;&nbsp;&nbsp;<br />";

                rename("UPDATES/$id/$j.jpg","UPDATES/$id/$i.jpg");
        
                $returned = mysql_fetch_assoc($dbdata);
                
                $query1 = "UPDATE updates SET " . $i . "d = '"
                  .$returned[$j."d"]. "' WHERE id='" . $id . "'";
                
                if (!mysql_query($query1)) {
                        echo "MySQL Error: ".mysql_error();
                };
                
        }
}

I have a database in the following format. Let's say that "d" stands
for date, and "t" stands for times, and I have ten days' worth of
archives going on:

|id|1d|1t|2d|2t|3d|3t|.......|8d|8t|9d|9t|

I'm trying to "move" the contents of the previous field to the logical
next field, so the value of field "8d" becomes "9d", the value of "7t"
becomes the value of "8t", and so on.

The problem that I'm having here is that only the first iteration of the
for loop work properly. Everything after that, is not being pulled up
properly, I suspect. This is what MySQL shows:

174 Query SELECT * FROM updates WHERE id=5
174 Query UPDATE updates SET 9d = '2005-08-21' WHERE id='5'
174 Query UPDATE updates SET 8d = '' WHERE id='5'
....
174 Query UPDATE updates SET 1d = '' WHERE id='5'
174 Query UPDATE updates SET 0d = '' WHERE id='5'

So all in all, I think I might be a bit out of my league here, but I am
eager to learn. I think of this as more of a dynamic approach to a
situation that I'm trying to adapt to.

As always, any feedback, or flames for that matter, would be greatly
appreciated.

Thanks
-dant

attached mail follows:


Dan,

When you run the second query ("$query1"), its results overwrite the
results of your first query ("$query0"). `mysql_fetch_assoc()'
returns results from the _most recent_ query, so after the first
iteration, the call to `mysql_fetch_assoc()' is returning results
from `query1', not from `query0'.

To solve this, retrieve all data from `query0' before iterating over
it. Sample code in /painstakingly exact/ PHP which I have tested
extensively:

<?"php"

run query0

while( rows exist )
     $rows[] = get next row

foreach $rows
     for i = 0; i >= 0; i-- {
        build query1
        run query1
        }
?>

Excellent description of your problem, by the way; this one's tricky
and definitely had me for a while when I first ran into it.

Evan

On Aug 21, 2005, at 7:24 AM, Dan Trainor wrote:

> Hello, all -
>
> As a pet project of mine, I've decided to write a bit of code.
> This is what I have, and it's not working as expected:
>
> if ($action == "prepareforupdate") {
> unlink("UPDATES/".$id."/9.jpg");
> $query0 = "SELECT * FROM updates WHERE id=".$id."";
> if (!$dbdata = mysql_query($query0)) {
> echo "Can't run query: ".mysql_error();
> die;
> };
>
> for ($i = 9; $i >= 0; $i--) {
> $j = $i - 1;
>
> echo "Getting ready to rename UPDATES/$id/$j.jpg to
> UPDATES/$id/$i.jpg || &nbsp;&nbsp;&nbsp;&nbsp;<br />";
>
> rename("UPDATES/$id/$j.jpg","UPDATES/$id/$i.jpg");
>
> $returned = mysql_fetch_assoc($dbdata);
>
> $query1 = "UPDATE updates SET " . $i . "d = '"
> .$returned[$j."d"]. "' WHERE id='" . $id . "'";
>
> if (!mysql_query($query1)) {
> echo "MySQL Error: ".mysql_error();
> };
>
> }
> }
>
>
> I have a database in the following format. Let's say that "d"
> stands for date, and "t" stands for times, and I have ten days'
> worth of archives going on:
>
> |id|1d|1t|2d|2t|3d|3t|.......|8d|8t|9d|9t|
>
> I'm trying to "move" the contents of the previous field to the
> logical next field, so the value of field "8d" becomes "9d", the
> value of "7t" becomes the value of "8t", and so on.
>
> The problem that I'm having here is that only the first iteration
> of the for loop work properly. Everything after that, is not being
> pulled up properly, I suspect. This is what MySQL shows:
>
> 174 Query SELECT * FROM updates WHERE id=5
> 174 Query UPDATE updates SET 9d = '2005-08-21' WHERE id='5'
> 174 Query UPDATE updates SET 8d = '' WHERE id='5'
> ....
> 174 Query UPDATE updates SET 1d = '' WHERE id='5'
> 174 Query UPDATE updates SET 0d = '' WHERE id='5'
>
> So all in all, I think I might be a bit out of my league here, but
> I am eager to learn. I think of this as more of a dynamic approach
> to a situation that I'm trying to adapt to.
>
> As always, any feedback, or flames for that matter, would be
> greatly appreciated.
>
> Thanks
> -dant
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Evan Priestley wrote:
> Dan,
>
> When you run the second query ("$query1"), its results overwrite the
> results of your first query ("$query0"). `mysql_fetch_assoc()' returns
> results from the _most recent_ query, so after the first iteration, the
> call to `mysql_fetch_assoc()' is returning results from `query1', not
> from `query0'.
>
> To solve this, retrieve all data from `query0' before iterating over
> it. Sample code in /painstakingly exact/ PHP which I have tested
> extensively:
>
> <?"php"
>
> run query0
>
> while( rows exist )
> $rows[] = get next row
>
> foreach $rows
> for i = 0; i >= 0; i-- {
> build query1
> run query1
> }
> ?>
>
> Excellent description of your problem, by the way; this one's tricky
> and definitely had me for a while when I first ran into it.
>
> Evan
>
> On Aug 21, 2005, at 7:24 AM, Dan Trainor wrote:
>
>> Hello, all -
>>
>> As a pet project of mine, I've decided to write a bit of code. This
>> is what I have, and it's not working as expected:
>>
>> if ($action == "prepareforupdate") {
>> unlink("UPDATES/".$id."/9.jpg");
>> $query0 = "SELECT * FROM updates WHERE id=".$id."";
>> if (!$dbdata = mysql_query($query0)) {
>> echo "Can't run query: ".mysql_error();
>> die;
>> };
>>
>> for ($i = 9; $i >= 0; $i--) {
>> $j = $i - 1;
>>
>> echo "Getting ready to rename UPDATES/$id/$j.jpg to
>> UPDATES/$id/$i.jpg || &nbsp;&nbsp;&nbsp;&nbsp;<br />";
>>
>> rename("UPDATES/$id/$j.jpg","UPDATES/$id/$i.jpg");
>>
>> $returned = mysql_fetch_assoc($dbdata);
>>
>> $query1 = "UPDATE updates SET " . $i . "d = '"
>> .$returned[$j."d"]. "' WHERE id='" . $id . "'";
>>
>> if (!mysql_query($query1)) {
>> echo "MySQL Error: ".mysql_error();
>> };
>>
>> }
>> }
>>
>>
>> I have a database in the following format. Let's say that "d" stands
>> for date, and "t" stands for times, and I have ten days' worth of
>> archives going on:
>>
>> |id|1d|1t|2d|2t|3d|3t|.......|8d|8t|9d|9t|
>>
>> I'm trying to "move" the contents of the previous field to the
>> logical next field, so the value of field "8d" becomes "9d", the
>> value of "7t" becomes the value of "8t", and so on.
>>
>> The problem that I'm having here is that only the first iteration of
>> the for loop work properly. Everything after that, is not being
>> pulled up properly, I suspect. This is what MySQL shows:
>>
>> 174 Query SELECT * FROM updates WHERE id=5
>> 174 Query UPDATE updates SET 9d = '2005-08-21' WHERE id='5'
>> 174 Query UPDATE updates SET 8d = '' WHERE id='5'
>> ....
>> 174 Query UPDATE updates SET 1d = '' WHERE id='5'
>> 174 Query UPDATE updates SET 0d = '' WHERE id='5'
>>
>> So all in all, I think I might be a bit out of my league here, but I
>> am eager to learn. I think of this as more of a dynamic approach to
>> a situation that I'm trying to adapt to.
>>
>> As always, any feedback, or flames for that matter, would be greatly
>> appreciated.
>>
>> Thanks
>> -dant
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
Hello, Evan, and thanks for your reply -

I was under the impression that, since I specified $dbdata as the
argument to mysql_fetch_assoc(), that this would work exclusively with
query0. I'm a bit confused as to how query0's return is getting
overwritten, since I've tried to keep query0 and query1 seperate.

I'm going to drop this whole script, since I've found a much better way
of keeping records of updates involving one big-ass database, but I'd at
least like to know what I did wrong in this instance, so that I at least
learn something. Your explanation was very helpful, but please clarify,
if you would be so kind.

Thanks
-dant

attached mail follows:


I've never really examined the code behind the PHP/MySQL API, but I
would assume, that it is mainly a wrapper for the C MySQL API.

Do you know how to interact with this database in any other language
such as C, Perl, Java etc?

I don't know much about prolog, but a look at www.swi-prolog.org
suggests that it has a two-way C interface. You'd exploit this, by
writing a php Extension in C(see PHP manual), that would interact with
 your prolog app, using the two-way C/C++ interface.

I don't know Prolog, nor anything about it, except that it seems to be
a functional programming language, so take these comments in that
reference frame.

On 8/21/05, Fernando Garza <ferdrggmail.com> wrote:
> Hi,
>
> I am creating a Shell in prolog language that interacts with a Visual Prolog
> database format in Win32, I would like to interact with this database with
> PHP, just like the interaction with MySQL database, can you give me some
> notion or the code that need to be executed to get this done? for example
> in:
>
> mysql_connect
>
> or
>
> mysql_create_db
>
> what code is executed behind this functions?
>
>
> I think the functions to make this done should be execute a program with
> some function, passes values and receive values from the shell
>
>
> any idea?
>
>

attached mail follows:


Fernando Garza wrote:
> Hi,
>
> I am creating a Shell in prolog language that interacts with a Visual Prolog
> database format in Win32, I would like to interact with this database with
> PHP, just like the interaction with MySQL database, can you give me some
> notion or the code that need to be executed to get this done? for example
> in:
>
> mysql_connect
>
> or
>
> mysql_create_db
>
> what code is executed behind this functions?
>
>
> I think the functions to make this done should be execute a program with
> some function, passes values and receive values from the shell

These are PHP functions implemented as wrappers around MySQL's C API.
There is no such extension for Prolog.

If your database has an ODBC driver then you can use odbc_* set of
functions.

Edin

attached mail follows:


Hello All,

 

I have a series of thumbnails on my site of photos I've taken that are all
150px in width, but of variable height. I want to randomly display one of
the thumbnails each time the home page of my site is loaded in a column that
is 140px wide.

 

I'm wondering if anyone can point me at some code that would achieve this?
All of the thumbnails are in jpg format.

 

So, essentially, I'm trying to resize the thumbnails down to 140px wide
while maintaining the aspect ratio of the image's height.

 

I have GD enabled.

 

Any help appreciated!

 

Much warmth,

 

Murray

---

http://www.planetthoughtful.org

"Building a thoughtful planet,

one quirky comment at a time."