php-general Digest 2 Sep 2003 00:18:06 -0000 Issue 2272

Topics (messages 161360 through 161403):

gif support not in GD 2.01?
        161360 by: Merlin
        161369 by: Curt Zirzow

Re: reinstalling php with imap
        161361 by: Raditha Dissanayake
        161362 by: Merlin
        161363 by: Raditha Dissanayake

backtick : maximum output size?
        161364 by: Mark Walker
        161370 by: Curt Zirzow

session.cookie_domain
        161365 by: Diana Castillo
        161368 by: Tom Percival

Re: cookie crumbles
        161366 by: John W. Holmes

php 5 - mysql replication
        161367 by: Moritz Steiner
        161371 by: Curt Zirzow

Display one element at a time
        161372 by: Mike Capps
        161375 by: Seth Willits

New User Script Failing Unexpectedly.
        161373 by: Adam Bishop
        161380 by: Curt Zirzow
        161381 by: Chris Sherwood
        161387 by: Adam Bishop

Can't Connect Within Function?!
        161374 by: Seth Willits
        161376 by: Curt Zirzow
        161377 by: Mike Morton
        161378 by: Seth Willits
        161383 by: Dan Anderson

Write RegExp-Vars in a function
        161379 by: Niels Uhlendorf
        161382 by: Curt Zirzow

Linux support and security services
        161384 by: Desi

can someone explain...
        161385 by: jsWalter
        161386 by: Catalin Trifu

Re: Tracking Bandwidth usage....
        161388 by: Desi

MySQL Left Join Question
        161389 by: Van Andel, Robbert

Can't Make Directories Now
        161390 by: Seth Willits
        161393 by: Curt Zirzow
        161399 by: Seth Willits
        161400 by: Seth Willits

Re: parent classes
        161391 by: Cristiano Duarte

randomly select a table, better way?
        161392 by: Daniel Bray
        161395 by: Curt Zirzow
        161403 by: Daniel Bray

session-problem
        161394 by: Juerg Zgraggen
        161396 by: Juerg Zgraggen
        161397 by: Curt Zirzow
        161398 by: Curt Zirzow
        161401 by: Juerg Zgraggen

TIME
        161402 by: Dale Hersh

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

I have included a imagecreatefromgif() into my code which runns pretty fine on my testsystem 4.3.3

Now I uploaded it to the live system where an older version is running and is build with GD2.0.1. This is causing an error. Is this function not included inside the gd version?

Thanx,

Merlin
--- End Message ---
--- Begin Message ---
* Thus wrote Merlin ([EMAIL PROTECTED]):
> Hi there,

Hello merlin.
> 
> I have included a imagecreatefromgif() into my code which runns pretty 
> fine on my testsystem 4.3.3
> 
> Now I uploaded it to the live system where an older version is running 
> and is build with GD2.0.1. This is causing an error. Is this function 
> not included inside the gd version?

hm.. I've got gd 2.015 with php 4.3.3rc1 and it works fine. Are you
getting a function not defined error? 

Take a look at the phpinfo() output, particularly the GD section, mine
says:

   GIF Read Support: enabled 



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- There are two magical commands on linux called 'locate' and 'find' :-) if you have locate just type
locate c-client or some filename associated with the imap lib.


find is more complicated you could try something like

find / -name 'c-client*' | more

the above will search your whole hard disk so it could take some time.



Merlin wrote:

Hi there,

I would like to upgrade to the latest php version.

My old version was build with imap a year ago. Now I found, that the directory which contained the imap files:
'--with-imap=/home/sw/horde/imap-2002.RC2' '
does not longer exist. So I guess I have to rebuild the c-client library?
Is there a way around this? I am getting errors I cant solve while installing the c-client. The old c-client should be anywhere on the system, since php is running fine at the moment, right?


Can anybody give me an advice how to solve this dilema?

Thanx,

Merlin



--
http://www.raditha.com/php/progress.php
A progress bar for PHP file uploads.

--- End Message ---
--- Begin Message --- oh... thanx. There is a c-client.a on the system.

Is it possible just to add '--with-lmap=/home/sw/c-client.a' and it will work?

Merlin


Raditha Dissanayake wrote:


There are two magical commands on linux called 'locate' and 'find' :-) if you have locate just type
locate c-client or some filename associated with the imap lib.


find is more complicated you could try something like

find / -name 'c-client*' | more

the above will search your whole hard disk so it could take some time.



Merlin wrote:

Hi there,

I would like to upgrade to the latest php version.

My old version was build with imap a year ago. Now I found, that the directory which contained the imap files:
'--with-imap=/home/sw/horde/imap-2002.RC2' '
does not longer exist. So I guess I have to rebuild the c-client library?
Is there a way around this? I am getting errors I cant solve while installing the c-client. The old c-client should be anywhere on the system, since php is running fine at the moment, right?


Can anybody give me an advice how to solve this dilema?

Thanx,

Merlin




--- End Message ---
--- Begin Message --- You will need the header files as well. I belive you are using the washignton uni. imap system. why don't you download a new tarball?

all the best


Merlin wrote:


oh... thanx. There is a c-client.a on the system.

Is it possible just to add '--with-lmap=/home/sw/c-client.a' and it will work?

Merlin


Raditha Dissanayake wrote:


There are two magical commands on linux called 'locate' and 'find' :-) if you have locate just type
locate c-client or some filename associated with the imap lib.


find is more complicated you could try something like

find / -name 'c-client*' | more

the above will search your whole hard disk so it could take some time.



Merlin wrote:

Hi there,

I would like to upgrade to the latest php version.

My old version was build with imap a year ago. Now I found, that the directory which contained the imap files:
'--with-imap=/home/sw/horde/imap-2002.RC2' '
does not longer exist. So I guess I have to rebuild the c-client library?
Is there a way around this? I am getting errors I cant solve while installing the c-client. The old c-client should be anywhere on the system, since php is running fine at the moment, right?


Can anybody give me an advice how to solve this dilema?

Thanx,

Merlin





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

I'm using backticks to run a program (actually isoinfo), and then present
the information to the users of my site.

Everything is fine *most* of the time.  I have one .iso file whose contents
end up as around a 9Meg file to be presented to the user.  PHP just
segfaults.  No error, nothing, the php process just crashes.

Is this something I can modify in PHPs setup?
This is a stock MDK 91 setup, php 4.3.2, with mod_gzip 1.3.26.1a

Thanks for any help

Mark

--- End Message ---
--- Begin Message ---
* Thus wrote Mark Walker ([EMAIL PROTECTED]):
> Hi
> 
> I'm using backticks to run a program (actually isoinfo), and then present
> the information to the users of my site.
> 
> Everything is fine *most* of the time.  I have one .iso file whose contents
> end up as around a 9Meg file to be presented to the user.  PHP just
> segfaults.  No error, nothing, the php process just crashes.

9mb is a lot of data to pass around, consider using the passthru()
function:
  http://php.net/passthru

Or saving the output to a file then feeding that file to the user.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
I am using
ini_set("session.cookie_domain",".interhotel.com");
so that session variables wont get lost between a domain called
www.interhotel.com
and res.interhotel.com but they still get lost !
does this function work perfectly, or am I doign something wrong?



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

I'm pretty sure that if you use:

ini_set("session.cookie_domain","interhotel.com");

(i.e. no dot before the domain) then that should work

tommy


"Diana Castillo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> I am using
> ini_set("session.cookie_domain",".interhotel.com");
> so that session variables wont get lost between a domain called
> www.interhotel.com
> and res.interhotel.com but they still get lost !
> does this function work perfectly, or am I doign something wrong?
>
>

--- End Message ---
--- Begin Message --- John Taylor-Johnston wrote:
$StudentId = "weather.htm99999995";

if (!isset($_COOKIE["weather.htm$StudentId"]))

if(!isset($_COOKIE[$StudentID]))


{
echo "Cookie not found, not reading weather.htm$StudentId<br>";
echo "\$_COOKIE[\"weather.htm$StudentId\"]".
$_COOKIE["weather.htm$StudentId"]."-<hr>";

}else{
echo "cookie found, yay! ".$_COOKIE["weather.htm$StudentId"]."-<hr>";

echo "cookie found, yay! ".$_COOKIE[$StudentId]."-<hr>";


#phpinfo();
}
?>



--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I've heard that php 5 is going to support mysql replication, has anyone
more details about it, it is already working in the beta release?

Moritz

--- End Message ---
--- Begin Message ---
* Thus wrote Moritz Steiner ([EMAIL PROTECTED]):
> I've heard that php 5 is going to support mysql replication, has anyone
> more details about it, it is already working in the beta release?

Can you enlighten me as to what special things php needs to do
replication?

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Nothing seems to work. I have try every thing. At least all of the obvious like 
pos(array) or $element = current($array) .

What I am trying to do :
 Is to ask questions (the problem I am having, display only one at a time)
get answer by using a check box
move and display next question (part of the problem)

At this point my alternative is to go ahead and print all the questions with check 
boxs. Not what I wont to do.

If any one can help please email me at [EMAIL PROTECTED] 
thanks in advance 

--- End Message ---
--- Begin Message --- On Monday, September 1, 2003, at 10:32 AM, Mike Capps wrote:

Nothing seems to work. I have try every thing. At least all of the obvious like pos(array) or $element = current($array) .

What I am trying to do :
Is to ask questions (the problem I am having, display only one at a time)
get answer by using a check box
move and display next question (part of the problem)


At this point my alternative is to go ahead and print all the questions with check boxs. Not what I wont to do.

You'd have one page and which would keep posting to itself.


First create a record in the database for the answers. Pass the question number you're currently on (i.e. 1, 2, 3...) AND the record ID for the "answers" record (using hidden input fields). Each time the page loads you'd retrieve the question for that question number from the database, and store the previous question's value in the "answers" record. Your question answer checkboxes and the hidden fields should be within a POST form (or a get form, doesn't really matter) where the action is the same page.

In this page you'll have to test for when the current question number is greater than the last answer of the last question and when it is, you'd include() or require() the "Thank you for answering" text OR, test when it is EQUAL (ie showing the last page) and change the form action to a different page if you want. Note that if you were to do the latter, the "different" page would also have to add the answer to the record.

Hope this helps,



Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"In the eyes of others, spending a lifetime chasing a dream is often seen
as a lavish waste of a one-time gift, but maybe the joy isn't solely in
its catching, but also in its pursuit."
-- Seth Willits
------------------------------------------------------------------------ ---

--- End Message ---
--- Begin Message ---
Okay, this is a tricky one (i think so, anyway!), and rather long but pleeeeeeeease 
help me!  I don't expect you to spend hours looking at the problem, but any insight is 
appreciated.

I am (trying) to create a members only website.  However, I am having a spot of 
bother.  It all works perfectly... The second time you fill in any form.

first, the user goes to newuser_process.php (Sample A) (the same thing happens if the 
user goes to apply.php, I might add).

Then, the user fills in the form, and submits it to newuser_process.php

the program then checks for blank fields, which it finds none.  it then goes on to 
check individual fields, and here it hangs.

it executes the if block (even though the condition is not true), and re-shows the 
form, with the error message, but with nothing in the fields.

If you fill in the form again, it works.

help!!!

So far, I have re-arranged the validation order, to see if that makes a difference, 
but it always fails on the first if loop.

I have also tried to manually recreate the variables on sample 'B' (apply.php) (shown 
in green, if you have html formatting enabled.

Other than that, I am totally clueless.

You can reach me at any of the adresses at the end of the e mail, for any solutions, 
queries about my aims/ideals in this script, or anything else.

P.s.  The .inc files and .js files are totally unrelated to the newuser script.

Thanks,

Adam Bishop

Sample 'A'

<?PHP
switch (@$do)
{
case "process":
session_start();
session_register('Sauth');
session_register('Slogname');
session_register('Spermissionlevel');
session_register('Sapprove');
include("thing.inc");

foreach($HTTP_POST_VARS as $key2 => $value2)
{
$$key2 = $value2;
}

foreach($HTTP_POST_VARS as $key => $value)
{
if ($key != "address2") 
{
if ($key != "mobno")
{
if ($value == "")
{
unset($do);
$message_new = "You have missed a required field.  Please check back and fill in the 
required data";
include("apply.php");
exit();
}
}
}
$$key = strip_tags(trim($value));
}//end of foreach loop

if (!ereg("^[0-9]{11,11}$",$telno))
{
unset($do);
$message_new = "Your telephone number does not appear to be valid.  Please try again.";
include("apply.php");
exit();
}

if ($mobno != "")
{
if (!ereg("^[0-9]{11,11}$",$mobno))
{
unset($do);
$message_new = "Your mobile number does not appear to be valid.  Please try again.";
include("apply.php");
exit();
}
}

if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email))
{
unset($do);
$message_new = "Your e mail address does not appear to be valid.  Please try again.";
include("apply.php");
exit();
}

if ($password != $password2)
{
unset($do);
$message_new = "Your passwords do not match.  Please try again.";
include("apply.php");
exit();
}

$connection = mysql_connect($host,$user,$password) or die("Couldn't Connect to 
server");
$sql = "SELECT username FROM members WHERE username='$username'";
$result = mysql_query($sql) or die("Failed to check user name");
$num = mysql_numrows($result);

if ($num != 0)
{
unset($do);
$message_new = "Username already taken.  Please choose another.";
include("apply.php");
exit();
}

else
{
/*Submits user to database.*/
}
default:
include("apply.php");
}
?>

sample 'B'

<?PHP
include("thing.inc");
foreach(HTTP_POST_VARS as $key3 => $value3)
{
$$key3 = $value3;
}
?>
<HTML>
<HEAD>

<!--The next section calls up the external files-->

<LINK REL=StyleSheet HREF="css/default.css" TYPE="text/css" MEDIA="screen">
<SCRIPT SRC="js/functions.js" LANGUAGE="JAVASCRIPT">
</SCRIPT>

<TITLE>
Welcome to the Didcot Explorers Website
</TITLE>

</HEAD>

<BODY>

<!--This table contains only the title image-->

<TABLE BORDER="0" BGCOLOR="WHITE" CELLSPACING="15" CELLPADDING="0" WIDTH="100%">
<TR>
<TD COLSPAN="2"  BGCOLOR="WHITE">
<IMG SRC="images/title.jpg"></TD>
</TR>
</TABLE>

<!--This table contains everything else-->

<TABLE BORDER="0" BGCOLOR="WHITE"  CELLSPACING="15" CELLPADDING="3" WIDTH="100%">
<TR>

<!--This cell contains the word 'navigation'-->

<TD WIDTH="18%" CLASS="navigation">
<CENTER>
Navigation
</CENTER>
</TD>

<TD ROWSPAN="2" WIDTH="82%" CLASS="2"  VALIGN="TOP">
<!--This is the main frame.  Put the main body of the file here-->

<H2><B><I>Becoming A Member:</I></B></H2>
<P>
In order to become a member of the Didcot Explorer website, you must be an attending 
member.  If you still want to become a member, you must fill in all of this form.
<P>
<?PHP
if (isset($message_new))
{
echo "<FONT COLOR='RED'><B>$message_new</B></FONT>";
}
?>
<CENTER>
<FORM ACTION="newuser_process.php?do=process" METHOD="POST">
<TABLE BORDER="0" WIDTH="85%">

<TR><TD COLSPAN="2"><B><I>Names:</B></I></TD></TR>

<TR><TD ALIGN="RIGHT">First Name: </TD><TD><INPUT TYPE="TEXT" NAME="fname" 
VALUE="<?PHP echo @$fname ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">Second Name: </TD><TD><INPUT TYPE="TEXT" NAME="lname" 
VALUE="<?PHP echo @$lname ?>"></TD></TR>

<TR></TR>

<TR><TD COLSPAN="2"><B><I>Address:</B></I></TD></TR>

<TR><TD ALIGN="RIGHT">1st Line of Address: </TD><TD><INPUT TYPE="TEXT" NAME="address1" 
VALUE="<?PHP echo @$address1 ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">2nd Line of Address: <BR><FONT 
SIZE="2">(optional)</TD><TD><INPUT TYPE="TEXT" NAME="address2" VALUE="<?PHP echo 
@$address2 ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">Town: </TD><TD><INPUT TYPE="TEXT" NAME="town" VALUE="<?PHP echo 
@$town ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">County: </TD><TD><INPUT TYPE="TEXT" NAME="county" VALUE="<?PHP 
echo @$county ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">Postcode: </TD><TD><INPUT TYPE="TEXT" NAME="postcode" 
VALUE="<?PHP echo @$postcode ?>"></TD></TR>

<TR></TR>

<TR><TD COLSPAN="2"><B><I>Contact Numbers:</B></I></TD></TR>

<TR><TD ALIGN="RIGHT">Telephone Number: <BR><FONT SIZE="2">(inc. Area 
code)</TD><TD><INPUT TYPE="TEXT" NAME="telno" VALUE="<?PHP echo @$telno ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">Mobile Number: <BR><FONT SIZE="2">(optional)</TD><TD><INPUT 
TYPE="TEXT" NAME="mobno" VALUE="<?PHP echo @$mobno ?>"></TD></TR>

<INPUT TYPE="HIDDEN" NAME="permission" VALUE="1">

<INPUT TYPE="HIDDEN" NAME="approve" VALUE="No">

<TR></TR>

<TR><TD COLSPAN="2"><B><I>User Details:</B></I></TD></TR>

<TR><TD ALIGN="RIGHT">E-mail address: </TD><TD><INPUT TYPE="TEXT" NAME="email"  
VALUE="<?PHP echo @$email ?>"></TD></TR>

<TR><TD COLSPAN="2"><B><I>Please Select the Following:</B></I></TD></TR>
<TR><TD ALIGN="RIGHT">Username: </TD><TD><INPUT TYPE="TEXT" NAME="username"  
VALUE="<?PHP echo @$username ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">Password: </TD><TD><INPUT TYPE="PASSWORD" NAME="password"  
VALUE="<?PHP echo @$password ?>"></TD></TR>

<TR><TD ALIGN="RIGHT">Confirm Password: </TD><TD><INPUT TYPE="PASSWORD" 
NAME="password2"  VALUE="<?PHP echo @$password2 ?>"></TD></TR>

<TR><TD COLSPAN="2"><CENTER><INPUT TYPE="Submit"  VALUE="Apply For Membership">
<INPUT TYPE="Reset" VALUE="Reset Form"></CENTER></TD></TR>

</FORM>
</TABLE>
</CENTER>
</TD>
<TR>
<?PHP
include("inc/navigation.inc");
?>
</TR>
</TABLE>
</BODY>
</HTML>


[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
 
_________________________________________________________________
 Stay in touch with absent friends - get MSN Messenger
 http://www.msn.co.uk/messenger

--- End Message ---
--- Begin Message ---
312 lines is a lot of stuff to filter through, you should really
isolate your problem.   

* Thus wrote Adam Bishop ([EMAIL PROTECTED]):
> Sample 'A'
> 
> <?PHP

This is an xml tag, it should read <?php (all lowercase)

> switch (@$do)
> {
> case "process":

You should indent, it makes the code more readable.

> session_start();
> session_register('Sauth');
> session_register('Slogname');
> session_register('Spermissionlevel');
> session_register('Sapprove');

Consider using $_SESSION instead of the old method of
session_register.

> include("thing.inc");
> 
> foreach($HTTP_POST_VARS as $key2 => $value2)
> {
> $$key2 = $value2;

You already have register_globals on, thus this is pointless. And
also strongly discouraged.

> }
> 
> 
> [..snip..]
> 
> $connection = mysql_connect($host,$user,$password) or die("Couldn't Connect to 
> server");
> $sql = "SELECT username FROM members WHERE username='$username'";
> $result = mysql_query($sql) or die("Failed to check user name");
> $num = mysql_numrows($result);

This should be mysql_num_rows($result);

> 
> if ($num != 0)



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
If this is causing all forms to need to be submitted twice, I would be
suspect of the include files that were found in all the forms documents and
start my debugging process from there.

just cursory glance tells me I would like to see the include files. before I
could say that it was one thing or another.

also you dont have a break on your process case statement so it will carry
out the default and include the apply.inc file again.

only other thing is not having a ; at the end of your error suppressed echos
dont cause a problem?

Chris Sherwood

--- <SNIP> ---

Okay, this is a tricky one (i think so, anyway!), and rather long but
pleeeeeeeease help me!  I don't expect you to spend hours looking at the
problem, but any insight is appreciated.

I am (trying) to create a members only website.  However, I am having a spot
of bother.  It all works perfectly... The second time you fill in any form.

first, the user goes to newuser_process.php (Sample A) (the same thing
happens if the user goes to apply.php, I might add).

Then, the user fills in the form, and submits it to newuser_process.php

the program then checks for blank fields, which it finds none.  it then goes
on to check individual fields, and here it hangs.

it executes the if block (even though the condition is not true), and
re-shows the form, with the error message, but with nothing in the fields.

If you fill in the form again, it works.

help!!!

So far, I have re-arranged the validation order, to see if that makes a
difference, but it always fails on the first if loop.

I have also tried to manually recreate the variables on sample 'B'
(apply.php) (shown in green, if you have html formatting enabled.

Other than that, I am totally clueless.

You can reach me at any of the adresses at the end of the e mail, for any
solutions, queries about my aims/ideals in this script, or anything else.

P.s.  The .inc files and .js files are totally unrelated to the newuser
script.

-- <SNIP> --

--- End Message ---
--- Begin Message ---
Thanks for all your help, but I ma still no closer to finding the problem.

I'll try decomiling the whole application, and rewriting it, see it that
works.
If anyone has a brainwave in the meantime, any further help would be greatly
appreciated.

Thanks,

Adam Bishop

P.S. I have replaced the break command, got rid of the extra foreach loops,
re-written mysql_num_rows, and put in a few extra semicolons.
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

_________________________________________________________________
 Stay in touch with absent friends - get MSN Messenger
 http://www.msn.co.uk/messenger

--- End Message ---
--- Begin Message --- If I try to connect to a database within a function, I get the following error. Why is this?


MySQL Connect Error : Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (2)


function getUserPermissions() {
if ($_SESSION['permissions'] == '') {
// Connecting, selecting database
$link = mysql_connect($shs_MySQLServer, $shs_MySQLUser, $shs_MySQLPassword)
or die("MySQL Connect Error : " . mysql_error());

etc....
}
}



Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"When purchasing that gift for your Special Someone guys remember, girls
like cute things. If it makes you want to puke, your chick will totally
love it."
-- Someone else out There
------------------------------------------------------------------------ ---

--- End Message ---
--- Begin Message ---
* Thus wrote Seth Willits ([EMAIL PROTECTED]):
> If I try to connect to a database within a function, I get the  
> following error. Why is this?
> 
> 
> MySQL Connect Error : Can't connect to local MySQL server through  
> socket '/Private/tmp/mysql.sock' (2)
> 
> function getUserPermissions() {
>       if ($_SESSION['permissions'] == '') {
>               // Connecting, selecting database
>               $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser,  
> $shs_MySQLPassword)

Youre $shs_ vars are not defined here.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
You need to read up on the scope of variables within functions.

You should have something like:

function 
getUserPermissions($shs_MySQLServer,$shsMySQLUser,$shs_MySQLPassword) {
 if ($_SESSION['permissions'] == '') {
 // Connecting, selecting database
 $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser,
 $shs_MySQLPassword)
 or die("MySQL Connect Error : " . mysql_error());
 
 etc....
 }
}

And call it with:
GetUserPermissions("server","user","password") where server,user and
password are the variables that contain those values.


On 9/1/03 2:20 PM, "Seth Willits" <[EMAIL PROTECTED]> wrote:

> If I try to connect to a database within a function, I get the
> following error. Why is this?
> 
> 
> MySQL Connect Error : Can't connect to local MySQL server through
> socket '/Private/tmp/mysql.sock' (2)
> 
> function getUserPermissions() {
> if ($_SESSION['permissions'] == '') {
> // Connecting, selecting database
> $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser,
> $shs_MySQLPassword)
> or die("MySQL Connect Error : " . mysql_error());
> 
> etc....
> }
> }
> 
> 
> Seth Willits
> ------------------------------------------------------------------------
> ---
> President and Head Developer of Freak Software - http://www.freaksw.com
> Q&A Columnist for REALbasic Developer Magazine -
> http://www.rbdeveloper.com
> Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames
> 
> "When purchasing that gift for your Special Someone guys remember, girls
> like cute things. If it makes you want to puke, your chick will totally
> love it."
>    -- Someone else out There
> ------------------------------------------------------------------------
> ---

--
Cheers

Mike Morton

****************************************************
*
* Tel: 905-465-1263
* Email: [EMAIL PROTECTED]
*
****************************************************

"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine

Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey 

--- End Message ---
--- Begin Message --- On Monday, September 1, 2003, at 11:33 AM, Mike Morton wrote:

You need to read up on the scope of variables within functions.

Ohh, I didn't even think of that. Thanks.



Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"It's okay. We can't all have three digit IQ levels."
-- Seth Willits
------------------------------------------------------------------------ ---

--- End Message ---
--- Begin Message ---
add this in the 1st line of the body of the function:

global $shs_MySQLServer;
global $shs_MySQLUser;
global $shs_MySQLPassword;

On Mon, 2003-09-01 at 14:20, Seth Willits wrote:
> If I try to connect to a database within a function, I get the  
> following error. Why is this?
> 
> 
> MySQL Connect Error : Can't connect to local MySQL server through  
> socket '/Private/tmp/mysql.sock' (2)
> 
> function getUserPermissions() {
>       if ($_SESSION['permissions'] == '') {
>               // Connecting, selecting database
>               $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser,  
> $shs_MySQLPassword)
>                       or die("MySQL Connect Error : " . mysql_error());
>               
>               etc....
>       }
> }
> 
> 
> Seth Willits
> ------------------------------------------------------------------------ 
> ---
> President and Head Developer of Freak Software - http://www.freaksw.com
> Q&A Columnist for REALbasic Developer Magazine -  
> http://www.rbdeveloper.com
> Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames
> 
> "When purchasing that gift for your Special Someone guys remember, girls
> like cute things. If it makes you want to puke, your chick will totally
> love it."
>      -- Someone else out There
> ------------------------------------------------------------------------ 
> ---

--- End Message ---
--- Begin Message --- Hi,

Although this seemed to be an easy prob I couldn't solve it in all the time.

I have a function and a string i want to be replaced. I use preg_replace and get a var out. Now I want this var in the function but I don't know how I can get it in:

preg_replace("#\[\+\+(.*)\+\+\]#Uis",my_function($1),$str); doesnt work at all and lots of other variations do not as well.

Please to be helping.

Greets
Niels

--- End Message ---
--- Begin Message ---
* Thus wrote Niels Uhlendorf ([EMAIL PROTECTED]):
> Hi,
> 
> Although this seemed to be an easy prob I couldn't solve it in all the 
> time.
> 
> I have a function and a string i want to be replaced. I use preg_replace 
> and get a var out. Now I want this var in the function but I don't know 
> how I can get it in:
> 
> preg_replace("#\[\+\+(.*)\+\+\]#Uis",my_function($1),$str); doesnt work 
> at all and lots of other variations do not as well.

Your missing the /e modifier, and should quote the function (I
believe):

preg_replace("#\[\+\+(.*)\+\+\]#Uise",'my_function($1)',$str);

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- I offer Linux support and security services for your systems. I provide support for installation and configuration of dedicated webservers, remote administration and System services on Linux platforms, including:

- remote Server maintenance
- Network/system security
- Secure chrooted Apache
- Tux web accelerator
- Dynamic Firewalls
- anti DDOS configurations

Desi Petrovic
J. Stanislava 41
841 05 Bratislava
Slovak Republic

<[EMAIL PROTECTED]>
--- End Message ---
--- Begin Message ---
this difference bewteen A and B below?

A)    $a = &new className(true, 6);

B)    $a = new className(true, 6);     /* missing & on the NEW */

thanks

walter

--- End Message ---
--- Begin Message ---
        Hi,

http://de.php.net/manual/en/language.references.php

Cheers,
Catalin

"Jswalter" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> this difference bewteen A and B below?
>
> A)    $a = &new className(true, 6);
>
> B)    $a = new className(true, 6);     /* missing & on the NEW */
>
> thanks
>
> walter

--- End Message ---
--- Begin Message --- Hello,

Try webalizer... You must setup custom log format in httpd.conf to log virtual hosts and properly configure webalizer.

Regards

Desi Petrovic
Mediate s.r.o.
system administrator


Binay Agarwal wrote:
Hi All,

I need to track the bandwidth usage of the different sites hosted on a server. How can i achieve this using PHP,Apache,mysql under Linux environment.

Please suggest me as it is urgently needed by client.

Thanks

Binay


--- End Message ---
--- Begin Message ---
This may not be the best place to ask this question, but I'm running into a
problem when I perform a left join sql statement in PHP.  The sql statement
is as follows:

SELECT p.id
pid,p.designID,p.project_name,p.node,p.received,p.lots,p.ugfootage,p.aerialf
ootage,p.node,c.* FROM projects as p LEFT JOIN proSub as c on
p.id=c.projectID WHERE p.id=$id

I have verified that $id has a value.  What I'm finding is that when there
is no corresponding entry in proSub, the query returns nothing even though
LEFT JOIN is supposed to return the contents of the left table even if the
right table has no data.  The left data does have data and I am asking for
the correct value for p.id.  I've run into some other scripts on my site
where left join does not behave the way it's supposed to.

Any thoughts??

Robbert van Andel 

--- End Message ---
--- Begin Message --- I figured out the permissions issue to allow gd to create image files, but I also need to create folders for those images. I've come up with a routine (below) but it fails to create the directories. I've made sure that the directory that the first directory is created in has the appropriate permissions, but it doesn't work.

<?php
        $path = "path/path2/path3/path4/path5";
        $buildingPath = "existingFolder";
        $pathComponents = split("/", $path);

        
        foreach ($pathComponents as $value) {
                $buildingPath = $buildingPath . "/" . $value;
                print $buildingPath . '<br>';
                
                if (opendir($buildingPath) == false)
                        if (!mkdir($buildingPath))
                                print 'false <br>';
                else
                        closedir($buildingPath);
        }
        
?>


The paths to the folders its supposed to create are correct ($buildingPath), but it always prints false signaling that mkdir has failed.


This is the last remaining issue on getting my site finished. Well except for uploading, but I don't need that just yet.



Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"It's all about the belly fire."
-- David Sepe
------------------------------------------------------------------------ ---

--- End Message ---
--- Begin Message ---
* Thus wrote Seth Willits ([EMAIL PROTECTED]):
> <?php
>       $path = "path/path2/path3/path4/path5";
>       $buildingPath = "existingFolder";
>       $pathComponents = split("/", $path);
> 
>       
>       foreach ($pathComponents as $value) {
>               $buildingPath = $buildingPath . "/" . $value;
>               print $buildingPath . '<br>';
>               
>               if (opendir($buildingPath) == false)

There is a lot of overhead with using opendir just to see if the
directoy exists other alternatives you might want to use is:
  php.net/stat
  php.net/is_dir

Or you can use the system's mkdir command wich usually has a
paramater to make all directories if they don't exist:
  `mkdir -p path/to/new/dir/`


>                       if (!mkdir($buildingPath))
>                               print 'false <br>';

A print("false  $buildingPath<br>") might yield as to why it isn't
creating it.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- On Monday, September 1, 2003, at 03:41 PM, Curt Zirzow wrote:

                print $buildingPath . '<br>';
                
                if (opendir($buildingPath) == false)
                        if (!mkdir($buildingPath))
                                print 'false <br>';

A print("false $buildingPath<br>") might yield as to why it isn't creating it.

I already did that and like I said, it's always the correct path. Look at the very first line of the code above which was in the original path.


Thanks for the tip on is_dir.


Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"Rather fail with honor than succeed by fraud."
-- Sophocles
------------------------------------------------------------------------ ---

--- End Message ---
--- Begin Message ---
                print $buildingPath . '<br>';
                
                if (opendir($buildingPath) == false)
                        if (!mkdir($buildingPath))
                                print 'false <br>';

A print("false $buildingPath<br>") might yield as to why it isn't creating it.

I already did that and like I said, it's always the correct path. Look at the very first line of the code above which was in the original path.


Thanks for the tip on is_dir.

Actually -- using is_dir made it work. I wonder why....



Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames


"Read the book! Be patient! All success comes from acquiring knowledge and experience."
-- Seth Willits
------------------------------------------------------------------------ ---

--- End Message ---
--- Begin Message ---
Ok. But if I have an instance... Is there a way to find all its class
parents ?

Cristiano

"Catalin Trifu" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
>         Hi,
>
>     If I'm not mistaking here, you can not find the parent(s)
> of a class  without an instance and it is quite logical.
>     Since PHP is not a compiled language, the parent
> is available only at runtime.
>
> Cheers,
> Catalin
>
>
> "Cristiano Duarte" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I want to iterate through parents of some class.
> > The function get_parent_class is not enough since it retrieves only the
> > first parent of an instance.
> > Is there a way to retrieve the parents of a class without having an
> instance
> > of this class ? And if I have an instance, can I retrieve all parent
> > classes?
> >
> > Cristiano Duarte.

--- End Message ---
--- Begin Message ---
Ok, I have looked through the archives on both MySQL and PHP's lists, but
I have not seen this asked or mentioned.  Weird, I thought this would be a
common thing.  Is there a better way to randomly select a table from a
database, than what I have come up with:

<?php
        srand ((float) microtime() * 10000000);
        $table_array = array ();
        mysql_connect("localhost", "mysql_user", "mysql_password");
        $result = mysql_list_tables("database_name");

        for ($i = 0; $i < mysql_num_rows($result); $i++)
        {
                $table_name = mysql_tablename($result, $i);
                array_push ($table_array , "$table_name");
        }
        
        $rand_keys = array_rand ($table_array, 2);
        echo "<br><br>Here is a random table: <b>" . 
$table_array[$rand_keys[0]]."</b><br>\n";
        
        mysql_free_result($result);
?>

thanks, 
DB

--- End Message ---
--- Begin Message ---
* Thus wrote Daniel Bray ([EMAIL PROTECTED]):
> Ok, I have looked through the archives on both MySQL and PHP's lists, but
> I have not seen this asked or mentioned.  Weird, I thought this would be a
> common thing.  Is there a better way to randomly select a table from a
> database, than what I have come up with:

I dont see how finding a random table could be a common thing.

> 
> <?php
>       srand ((float) microtime() * 10000000);

You don't need to call srand with php >= 4.2.0.

>       $table_array = array ();
>       mysql_connect("localhost", "mysql_user", "mysql_password");
>       $result = mysql_list_tables("database_name");
> 
>       for ($i = 0; $i < mysql_num_rows($result); $i++)
>       {
>               $table_name = mysql_tablename($result, $i);
>               array_push ($table_array , "$table_name");
>       }
>       
>       $rand_keys = array_rand ($table_array, 2);

Instead of looping through all the tables and building an array you
can do something like:

$n = mysql_num_rows($result);
$seek = mt_rand(0, $n-1);
mysql_data_seek($result, $seek);


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On Mon, 01 Sep 2003 22:49:55 +0000, Curt Zirzow wrote:
> 
> Instead of looping through all the tables and building an array you
> can do something like:
> 
> $n = mysql_num_rows($result);
> $seek = mt_rand(0, $n-1);
> mysql_data_seek($result, $seek);
> 
> 
> Curt

So then the total code would be:

<?
        $mysqlconnect = mysql_connect("localhost", "mysqladmin", "i.hate.microsoft");
        $result = mysql_list_tables("Bookmarks");
        
        $n = mysql_num_rows($result);
        $seek = mt_rand(0, $n-1);
        $random_table = mysql_data_seek($result, $seek);

        echo "<br><br>The randomly slected table was<b>$random_table</b><br><br>";
?>

If so, then this does not work for me.  All I get is $random_table == 1.  If not,
then what am I missing.

Thanks for your quick response, 
DB

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

got a big session-problem and i have no idea what i'm doing wrong...

i have quite a big web-app and i tried to upgrade the code.
ex:     $frm_id     to    $_POST['frm_id']
and    $HTTP_SESSION_VAR['myId']   to   $_SESSION['myId']
... ect...

i changed the register_globals = Off in the php.ini and tried to browse my
webapp.

now my problem: i wrote in my navigation-frame this code:
<?php
   if( !isset($_SESSION['testint'] ) )
   {
       $_SESSION['testint'] = 1;
   }
    $_SESSION['testint']++;
    print_r($_SESSION);
?>

after the print_r() i can see my 'testint'-session-variable on the
navigation-site. however on the other frame-site. i do NOT see this
'testint'-session-variable when i reload it. and when i reload the
navigation-frame the variable does appear but does NOT increase. isset()
always return false!!! when i take a look at the session-file on my
Computer, i do NOT find the variable 'testint'...

now when i make a complete new dummy php-file and copy-paste this
session-code on the navigation-site then the session works perfectly. even
when i call the navigation-site again AFTER processing this dummy-php-file.
the session for this variable works suddenly.

what am i doing wrong???
please give me a hint!
regards, jazper

--- End Message ---
--- Begin Message ---
Probably i got the problem... but i don't know how to solve it!!!

i include one of my class.
in the constructor of this class i did a global...
global $_SESSION;

as soon as i delete that line. my script works perfect...

is this not allowed anymore... to access $_SESSION in a constructor??

regards, jazper





"Juerg Zgraggen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> hi
>
> got a big session-problem and i have no idea what i'm doing wrong...
>
> i have quite a big web-app and i tried to upgrade the code.
> ex:     $frm_id     to    $_POST['frm_id']
> and    $HTTP_SESSION_VAR['myId']   to   $_SESSION['myId']
> ... ect...
>
> i changed the register_globals = Off in the php.ini and tried to browse my
> webapp.
>
> now my problem: i wrote in my navigation-frame this code:
> <?php
>    if( !isset($_SESSION['testint'] ) )
>    {
>        $_SESSION['testint'] = 1;
>    }
>     $_SESSION['testint']++;
>     print_r($_SESSION);
> ?>
>
> after the print_r() i can see my 'testint'-session-variable on the
> navigation-site. however on the other frame-site. i do NOT see this
> 'testint'-session-variable when i reload it. and when i reload the
> navigation-frame the variable does appear but does NOT increase. isset()
> always return false!!! when i take a look at the session-file on my
> Computer, i do NOT find the variable 'testint'...
>
> now when i make a complete new dummy php-file and copy-paste this
> session-code on the navigation-site then the session works perfectly. even
> when i call the navigation-site again AFTER processing this
dummy-php-file.
> the session for this variable works suddenly.
>
> what am i doing wrong???
> please give me a hint!
> regards, jazper

--- End Message ---
--- Begin Message ---
* Thus wrote Juerg Zgraggen ([EMAIL PROTECTED]):
> now my problem: i wrote in my navigation-frame this code:
> <?php
>    if( !isset($_SESSION['testint'] ) )
>    {
>        $_SESSION['testint'] = 1;
>    }
>     $_SESSION['testint']++;
>     print_r($_SESSION);
> ?>
> 
> after the print_r() i can see my 'testint'-session-variable on the
> navigation-site. however on the other frame-site. i do NOT see this
> 'testint'-session-variable when i reload it. and when i reload the
> navigation-frame the variable does appear but does NOT increase. isset()
> always return false!!! when i take a look at the session-file on my
> Computer, i do NOT find the variable 'testint'...

session_start() has been called right?



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
* Thus wrote Juerg Zgraggen ([EMAIL PROTECTED]):
> Probably i got the problem... but i don't know how to solve it!!!
> 
> i include one of my class.
> in the constructor of this class i did a global...
> global $_SESSION;
> 
> as soon as i delete that line. my script works perfect...
> 
> is this not allowed anymore... to access $_SESSION in a constructor??

$_SESSION is a superglobal meaning you don't need to and shouldn't
(as you found out the hard way :) global it.  You can access it
anytime:

class foo {
  function foo {
    $this->var = $_SESSION['var'];
  }
}

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
:-)  cool thank you!
is any "$_"-variable superglobal? $_REQUEST, $_POST, ...?

cheers,
jazper




"Curt Zirzow" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> * Thus wrote Juerg Zgraggen ([EMAIL PROTECTED]):
> > Probably i got the problem... but i don't know how to solve it!!!
> >
> > i include one of my class.
> > in the constructor of this class i did a global...
> > global $_SESSION;
> >
> > as soon as i delete that line. my script works perfect...
> >
> > is this not allowed anymore... to access $_SESSION in a constructor??
>
> $_SESSION is a superglobal meaning you don't need to and shouldn't
> (as you found out the hard way :) global it.  You can access it
> anytime:
>
> class foo {
>   function foo {
>     $this->var = $_SESSION['var'];
>   }
> }
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
The battery on my server keeps on dieing, so the clock is not keeping time
correctly. I was wondering is there any way to query some type of global
time source in php?

Thanks,
Dale

--- End Message ---

Reply via email to