php-general Digest 28 Apr 2005 09:08:33 -0000 Issue 3423

Topics (messages 214043 through 214062):

Re: Simple Question: Reading exec(locate) results into an array
        214043 by: John Nichel

Re: editor that typesets the php code
        214044 by: Rob Agar
        214049 by: Richard Lynch

What's changed between version 4.2.2 and 4.3.4 regarding POSTing?
        214045 by: mwestern.sola.com.au
        214046 by: Matthew Weier O'Phinney

temp tables
        214047 by: Cima
        214048 by: Richard Lynch
        214052 by: Joshua D. Drake

Avoiding Error : Maximum execution time of 30 seconds exceeded
        214050 by: Andri Heryandi
        214057 by: Richard Lynch

Re: Retrieving query from MSSQL Table
        214051 by: Richard Lynch

Re: LDAP and .htaccess
        214053 by: Richard Lynch

Re: Mac OS X compilation problem
        214054 by: Richard Lynch

Re: beginner volunteer
        214055 by: Richard Lynch

Re: Product details not being displayed, based on passed id
        214056 by: Richard Lynch
        214058 by: Mark Sargent

User Logout system advice needed...
        214059 by: William Stokes
        214060 by: Petar Nedyalkov

Skipping function arguments!
        214061 by: Vedanta Barooah

Global Variables
        214062 by: Dan

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 --- Karl Fry wrote:
Hello all,

I'm sure this is very rudimentary, sorry if this sounds ignorant. I've only dabbled a bit in other languages and I'm working with a
small knowledge of php since I only use it on-and-off at my job. I
scribbled up this script today at work off the top of my head for a
customer who was looking for a printout of my company's PEAR location.
I wanted something quick and easy that would be adaptable to find
other items. I was surprised it even worked since I haven't really
had a chance to dig into PHP yet:

<?php
$temp = exec("which pear");
$temp2 = exec("locate pear");
echo "which = $temp <BR><BR> locate = $temp2";
?>

When executing the commands directly within Unix, without the php script:

'which' yields 1 line: the path to the pear module for PHP

'locate' yields dozens of lines, paths to everything with 'pear' in it.

However, this is the printout when running the script from a browser
(same via command line) :

---
which = /usr/local/bin/pear

locate = /usr/ports/www/pear-HTTP_Upload/pkg-descr
---

It's only printing out a single line for locate.  I'm assuming i'd
need to run a loop to read all the lines of locate from an array.

My question is: what sort of general syntax can I use to get the
results from locate stored in an array so it can be read out?

I don't need a script written for me; a general nudge in the right
direction or the right website would be incredibly helpful.  I've had
trouble finding anything relevant thus far.

http://us4.php.net/manual/en/function.shell-exec.php

--
John C. Nichel
�berGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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

> From: Dasmeet Singh 
> I have just completed coding for a script... i want to take a 
> printout 
> of the code.. but the code is very hotch potch..
> 
> Is there any software to automatically set the code with proper 
> spacing/tabs extra..and possibly give colors to it too...??

Check out the PEAR PHP_Beautifier package
http://pear.php.net/package/PHP_Beautifier

R

--- End Message ---
--- Begin Message ---
On Wed, April 27, 2005 5:09 pm, Rob Agar said:
> hi Dasmeet
>
>> From: Dasmeet Singh
>> I have just completed coding for a script... i want to take a
>> printout
>> of the code.. but the code is very hotch potch..
>>
>> Is there any software to automatically set the code with proper
>> spacing/tabs extra..and possibly give colors to it too...??
>
> Check out the PEAR PHP_Beautifier package
> http://pear.php.net/package/PHP_Beautifier

You may also want to investigate http://php.net/syntax_highlight and friends.

Or just copy your hodgepodge.php to pretty.phps and surf to that.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
I've used the simple password script in the past to password protect
pages with a session.     http://www.phpbuddy.com/article.php?id=23
Now that I have installed Fedora Core 2 and 3 the new version of php
(4.3.4) doesn't like this script any more.    

Any ideas why?   

Thanks
Matthew


--- End Message ---
--- Begin Message ---
* [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> I've used the simple password script in the past to password protect
> pages with a session.     http://www.phpbuddy.com/article.php?id=23
> Now that I have installed Fedora Core 2 and 3 the new version of php
> (4.3.4) doesn't like this script any more. 
>
> Any ideas why?

Yes. It's using the global arrays HTTP_POST_VARS and HTTP_SESSION_VARS
arrays, and 4.3.x has the directive register_globals set to off by
default. It's safer to leave it off. You can easily update the script by
replacing these with $_POST and $_SESSION, respectively.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED]         | http://vermontbotanical.org

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

im working with php 4 and postgresql 8 and in my php script id like to create a 
temp table on my database server. how do i do this? how do i verify it was 
created?

i tried the following:

$sql = "create temp table s_info(a int, b text) on commit delete rows ";

pg_query($dbh,$sql);


$dbh is my connection.

any help will be highly appreciated.

--- End Message ---
--- Begin Message ---
On Wed, April 27, 2005 9:45 pm, Cima said:
> im working with php 4 and postgresql 8 and in my php script id like to
> create a temp table on my database server. how do i do this? how do i
> verify it was created?
>
> i tried the following:
>
> $sql = "create temp table s_info(a int, b text) on commit delete rows ";
>
> pg_query($dbh,$sql);
>
>
> $dbh is my connection.

Did it print an error message?

What was the return value of pg_query()?

Did you check http://php.net/pg_last_error

What happens if you then do:
$sql = "insert into s_info(a, b) values(1, 'Test')";
pg_query($dbh, $sql) or die(pg_last_error());

$sql = "select * from s_info";
$sinfo = pg_query($dbh, $sql) or die(pg_last_error());
$srow = 0;
while (list($a, $b) = @pg_fetch_row($sinfo, $srow++)){
  echo "a: $a b: $b<br />\n";
}

What makes you think it didn't work?

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message --- Cima wrote:
hi,

im working with php 4 and postgresql 8 and in my php script id like to create a 
temp table on my database server. how do i do this? how do i verify it was 
created?


Well if the creation fails pg_query will throw an error. However temp tables are only good for the life of the connection (script in this case). You will probably want to consider that.

Sincerely,

Joshua D. Drake



i tried the following:

$sql = "create temp table s_info(a int, b text) on commit delete rows ";

pg_query($dbh,$sql);


$dbh is my connection.

any help will be highly appreciated.


--
Your PostgreSQL solutions provider, Command Prompt, Inc.
24x7 support - 1.800.492.2240, programming, and consulting
Home of PostgreSQL Replicator, plPHP, plPerlNG and pgPHPToolkit
http://www.commandprompt.com / http://www.postgresql.org

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

I Have a script that need more than 30 second to complete.

How to avoid "*Fatal error*: Maximum execution time of 30 seconds exceeded in *\det.php* on line *66".

Thanks


*
--- End Message ---
--- Begin Message ---
On Wed, April 27, 2005 9:00 pm, Andri Heryandi said:
> I Have a script that need more than 30 second to complete.
>
> How to avoid "*Fatal error*: Maximum execution time of 30 seconds
> exceeded in *\det.php* on line *66".

http://php.net/set_time_limit

-- 
Like Music?
http://l-i-e.com/artists.htm

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



On Wed, April 27, 2005 1:29 pm, Mike Smith said:
> I have a form where I can submit a Query to be run against a MSSQL 2000
> Server.
> The query is stored correctly in a text (DataType) column. I can
> retrieve it echo it back to the screen, copy-n-paste into Query
> Analyzer and the query works.
>
> What I cannot do is get the query to be returned from the recordset
> and used to build a new recordset. Confused?
>
>     function preview_report(){
>             //Get the query
>           $s = "SELECT rptsql \n";
>           $s .= "FROM rpt_mas\n";
>           $s .= "WHERE id={$_POST['frm_rptid']}\n";
>           $r = $this->db->Execute($s);
>           $r_arr = $r->GetArray();
>           $sql1 = $r_arr[0][0]; //I can echo this to the screen and run
> it in Query Analyzer
>           $sql2 = "SELECT id, rptname, rptdesc, rptfile, rpttype,
> rptsql FROM rpt_mas";
>
>       if($sql!=""){
>               $this->xq = $sql;

if ($sql1 == $sql2){
  echo "They really are the same...<br />\n";
}
else{
  echo "They're not REALLY the same!<br />\n";
  for ($i = 0; $i = strlen($str1); $i++){
    $c1 = $str1[$i];
    $c2 = $str2[$i];
    $o1 = ord($c1);
    $o2 = ord($c2);
    if ($c1 != $c2){
      echo "At position $i, c1 is $c1 ($o1), and c2 is $c2 ($o2)<br />\n";
    }
  }
}

>               $r = $this->db->Execute($sql1);//This doesn't work

echo mssql_error(); //Or whatever this should be.

>               $r = $this->db->Execute($sql2);//This does work
>       }
>     }
>
> $sql1 & $sql2 are one and the same. Any ideas what I'm missing?

I'm betting dollars to doughnuts that you've got a newline at the end of
$sql1 which is messing you up.



-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Wed, April 27, 2005 12:08 pm, Bret Walker said:
> Well, the download.php script would allow me to protect certian files,
> but is there a way to protect all files?  For example, images that I
> would like to include in my php pages.

As noted, you could put your images outside the webtree and then use PHP
to serve them all up.

You would want to do this only for images you really cared about,
probably, for performance reasons.

> Could I silently pass a username and password to htaccess?  Can htaccess
> be set to use a php script instead of a htpasswd file?

Search http://php.net/ for HTTP Authentication.  You'll find a PHP script
that sends the same headers as .htaccess/htpasswd, and then you can use
LDAP there, or MySQL or whatever you want.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Wed, April 27, 2005 4:53 am, Marcus Bointon said:
> In the past I've had success compiling PHP4 on OS X. However, now I'm
> trying to get PHP5 working and not having much luck. I'm getting
> configure to work, and make goes ok until the final linking stage at
> which point I get this error:
>
> ld: unknown flag: -export-symbols
> make: *** [libs/libphp5.bundle] Error 1
>
> It seems that that flag must be set in a make file somewhere (it's not
> in my environment), and it's certainly not documented in the OS X ld
> man pages.
>
> Not sure if it makes any difference, but most of the external modules
> that PHP uses are built from fink. I need some modules that are not
> supported in any of the pre-built fink PHP5 packages, and I'm used to
> compiling it without difficulty on Linux and OpenBSD.
>
> Anyone else run into this or have any idea how I might fix it?

This is probably one of those boneheaded answers, but you could try to
edit the Makefile by hand and take out the -export-symbols and see what
happens...

Copy the file somewhere safe first, so you have a pristine copy to fall
back to when it doesn't work. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Wed, April 27, 2005 4:17 am, Malcolm Mill said:
> I've been reading up on php for a while now and would like to get
> involved in a small open source LAMP project. I don't have any real
> coding experience to speak of but could bring proofreading,
> bug-reporting, testing and documentation skills to the project. What
> I'd like to get out of working on it is: experience working with a
> variety of other individuals over the internet on a common
> application; real life knowledge of CVS and the development process;
> some experience writing simple code.
>
> If anyone knows of any opportunities like this or would like to
> discuss what I could add to one of their own projects please contact
> me.

You needn't wait for somebody to contact you.

Pick a task/project/whatever and dive in. :-)

Do ask, once you've chosen a likely target, if anybody is already doing X
-- Just to be sure you're not duplicating effort.

I think SourceForge.net might have a search engine to try to match up
skills with things that need doing.

I would imagine that just about every project could use more/better
documentation.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
http://php.net/register_globals

On Wed, April 27, 2005 12:20 am, Mark Sargent said:
> Petar Nedyalkov wrote:
>
>>On Wednesday 27 April 2005 08:54, Mark Sargent wrote:
>>
>>
>>>Hi All,
>>>
>>>this page,
>>>
>>>http://webmonkey.wired.com/webmonkey/99/21/index3a_page3.html?tw=programmin
>>>g
>>>
>>>has code that is supposed to pass an id via the url string to the same
>>>page, and display info of a particular product, based on the id being
>>>passed. Everything works fine, until I click the link, and instead of
>>>the proudct's details being displayed, based on that id, I get the
>>>original page, with the lnks. I've right clicked the links, and viewed
>>>properties, where I see that the id=n is set. Why doesn't it pull the
>>>record based on the id being passed..? Cheers.
>>>
>>>
>>
>>Are you sure your webserver handles it's rewrite rules correctly? Maybe
>> you
>>use apache - check the mod_rewrite settings, rules, etc.
>>
>>Have in mind that the rewrite engine is being enabled using the
>> "RewriteEngine
>>on" directive.
>>
>>
>>
>>>Mark Sargent.
>>>
>>>P.S. I've inserted, echo $id && to display the id value. Nothing
>>> appears.
>>>
>>>
>>><html>
>>>
>>><body>
>>>
>>><?php
>>>
>>>
>>>
>>>$db = mysql_connect("localhost", "root", "grunger");
>>>
>>>mysql_select_db("status",$db);
>>>
>>>// display individual record
>>>
>>>if ($id) {
>>>echo $id &&
>>>  $result = mysql_query("SELECT * FROM Products WHERE
>>> product_id=$id",$db);
>>>
>>>   $myrow = mysql_fetch_array($result);
>>>
>>>   printf("Product Name: %s\n<br>", $myrow["product_name"]);
>>>
>>>   printf("Product Model Number: %s\n<br>",
>>>$myrow["product_model_number"]);
>>>
>>>   printf("Product Serial Number: %s\n<br>",
>>>$myrow["product_serial_number"]);
>>>
>>>   printf("Product Price: %s\n<br>", $myrow["product_price"]);
>>>
>>>} else {
>>>
>>>    // show employee list
>>>
>>>   $result = mysql_query("SELECT * FROM Products",$db);
>>>
>>>    if ($myrow = mysql_fetch_array($result)) {
>>>
>>>      // display list if there are records to display
>>>
>>>      do {
>>>
>>>        printf("<a href=\"%s?id=%s\">%s</a><br>\n", $PHP_SELF,
>>>$myrow["product_id"], $myrow["product_name"]);
>>>
>>>      } while ($myrow = mysql_fetch_array($result));
>>>
>>>    } else {
>>>
>>>      // no records to display
>>>
>>>      echo "Sorry, no records were found!";
>>>
>>>    }
>>>
>>>}
>>>
>>>
>>>
>>>?>
>>>
>>>
>>>
>>></body>
>>>
>>>
>>>
>>></html>
>>>
>>>
>>
>>
>>
> Hi All,
>
> yes, using Apache2 as my test web server. I'm even more a novice with
> it. I'm not too sure I understand what you are asking me to check. I
> looked in apache2/conf/httpd.conf for somethig related to RewriteEngine,
> but found nothing. Could you explain a little more..? Cheers.
>
> Mark Sargent.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:

http://php.net/register_globals

On Wed, April 27, 2005 12:20 am, Mark Sargent said:


Petar Nedyalkov wrote:



On Wednesday 27 April 2005 08:54, Mark Sargent wrote:




Hi All,

this page,

http://webmonkey.wired.com/webmonkey/99/21/index3a_page3.html?tw=programmin
g

has code that is supposed to pass an id via the url string to the same
page, and display info of a particular product, based on the id being
passed. Everything works fine, until I click the link, and instead of
the proudct's details being displayed, based on that id, I get the
original page, with the lnks. I've right clicked the links, and viewed
properties, where I see that the id=n is set. Why doesn't it pull the
record based on the id being passed..? Cheers.




Are you sure your webserver handles it's rewrite rules correctly? Maybe
you
use apache - check the mod_rewrite settings, rules, etc.

Have in mind that the rewrite engine is being enabled using the
"RewriteEngine
on" directive.





Mark Sargent.

P.S. I've inserted, echo $id && to display the id value. Nothing
appears.


<html>

<body>

<?php



$db = mysql_connect("localhost", "root", "grunger");

mysql_select_db("status",$db);

// display individual record

if ($id) {
echo $id &&
$result = mysql_query("SELECT * FROM Products WHERE
product_id=$id",$db);

 $myrow = mysql_fetch_array($result);

 printf("Product Name: %s\n<br>", $myrow["product_name"]);

 printf("Product Model Number: %s\n<br>",
$myrow["product_model_number"]);

 printf("Product Serial Number: %s\n<br>",
$myrow["product_serial_number"]);

 printf("Product Price: %s\n<br>", $myrow["product_price"]);

} else {

  // show employee list

 $result = mysql_query("SELECT * FROM Products",$db);

  if ($myrow = mysql_fetch_array($result)) {

    // display list if there are records to display

    do {

      printf("<a href=\"%s?id=%s\">%s</a><br>\n", $PHP_SELF,
$myrow["product_id"], $myrow["product_name"]);

    } while ($myrow = mysql_fetch_array($result));

  } else {

    // no records to display

    echo "Sorry, no records were found!";

  }

}



?>



</body>



</html>







Hi All,

yes, using Apache2 as my test web server. I'm even more a novice with
it. I'm not too sure I understand what you are asking me to check. I
looked in apache2/conf/httpd.conf for somethig related to RewriteEngine,
but found nothing. Could you explain a little more..? Cheers.

Mark Sargent.

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








Hi All,

ok, so let me understand this. To be able to use GET/POST and some others, I need this turned on, yes..? Do you all have it set to on..? If no, how do you get around this..? Cheers.

Mark Sargent.
--- End Message ---
--- Begin Message ---
Hello,

I need to write some sort of  a user logout system for my web application. 
It needs to be a solid system so that if the user presses the Logout button 
there's no way of returning to the password protected area without logging 
in again. At the moment my "system" only tries to close browser window with 
javascript. This doesn't work if the user has more than one tab open in the 
browser and in Firefox it doesn't even close the active tab :-)

I use a cookie based session id so this probably needs to be deleted. Is 
there a way to delete all variables stored by the application or do I need 
to unset them one by one?

Any other things I might be missing here?

Thanks a Lot
-Will 

--- End Message ---
--- Begin Message ---
On Thursday 28 April 2005 08:48, William Stokes wrote:
> Hello,
>
> I need to write some sort of  a user logout system for my web application.
> It needs to be a solid system so that if the user presses the Logout button
> there's no way of returning to the password protected area without logging
> in again. At the moment my "system" only tries to close browser window with
> javascript. This doesn't work if the user has more than one tab open in the
> browser and in Firefox it doesn't even close the active tab :-)
>
> I use a cookie based session id so this probably needs to be deleted. Is
> there a way to delete all variables stored by the application or do I need
> to unset them one by one?

No, you just need to destroy the session (session_destroy()). This way all 
session associated data will be destroyed.

>
> Any other things I might be missing here?
>
> Thanks a Lot
> -Will

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436

Attachment: pgpuZp1IYgpaK.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
Hello All,
Cosider this :

function add($a=1,$b=2,$c=3){
        return $a + $b + $c;
}

how do i skip the second argument while calling the function, is there
a process like this:

echo add(1,,1); # where i expect 2 to be printed,

how do i xcheive this.... m totally lost ! :((
Thanks,
Vedanta

--- End Message ---
--- Begin Message ---
Hi all.

I taught myself PHP before the frenzy over register_globals.
After a reasonable break from the language, I'm back for more.

I'm building a site where I'll be holding a lot of variables in memory for each session. How do I do that? Apparently I can't use session_register() if register_globals is turned off. I've read a little about the consequences of writing bad scripts with register_globals on ... I'm fine with this explanation. I agree that I don't want people injecting variables into my session. What I want is for ME to be able to set variables and remember them throughout the session. How do I do that?

Dan
--- End Message ---

Reply via email to