php-general Digest 12 Jan 2002 05:57:48 -0000 Issue 1106

Topics (messages 80214 through 80265):

Re: Using PHP to post the contents of an email to MySql database
        80214 by: bvr.xs4all.nl
        80235 by: Mullin, Reginald

Paging using arrays Question
        80215 by: Lerp

Re: removing an array element
        80216 by: Rasmus Lerdorf
        80218 by: Henning Sprang
        80251 by: Erik Price

IMPORTANT about asking QUESTIONS
        80217 by: bvr.xs4all.nl
        80219 by: Jason Wong
        80232 by: l0t3k
        80243 by: Richard S. Crawford

Re: quick question
        80220 by: Philip Olson
        80245 by: Erik Price

Re: Q: Array
        80221 by: Ivo Stoykov
        80222 by: Ivo Stoykov
        80223 by: Ivo Stoykov
        80224 by: Ivo Stoykov
        80225 by: Ivo Stoykov

principiante(beginer)
        80226 by: vania
        80227 by: Nicolas Costes

Re: Newbie - PHP & MySQL
        80228 by: Henning Sprang

both work?  (was Re: [PHP] quick question)
        80229 by: Erik Price

memory error
        80230 by: Thomas Holton

Re: me and my CRON JOB
        80231 by: J Smith

PHP4.1.1 + RH7.2 + UCD-Snmp
        80233 by: Antonio S. Martins Jr.

PHP Sessions and SSL
        80234 by: Richard Hilton

Re: Cannot load: iconv_module_entry
        80236 by: Brian Williams
        80238 by: Brian Williams
        80247 by: Brian Clark

Using a HTML button
        80237 by: Morten Nielsen
        80239 by: J Smith
        80240 by: Nick Wilson
        80241 by: Nick Wilson
        80246 by: Richard S. Crawford
        80265 by: sundogcurt

using mysql_query() twice?
        80242 by: Erik Price
        80249 by: Nick Wilson
        80250 by: Erik Price
        80252 by: Nick Wilson
        80253 by: Erik Price

Fixed! Re: [PHP] headers showing up in browser
        80244 by: Mark

Sessions and SSL
        80248 by: Richard Hilton

Upload -> Link generator?
        80254 by: ArtistHotel

POSTing files
        80255 by: Alan McFarlane

Matching phrases in search engine
        80256 by: José Ignacio Franqueiro

Newbie looking for mentor
        80257 by: P. Westover

PHP question regarding Cold Fusion
        80258 by: Jeremy Reed
        80259 by: Rasmus Lerdorf

preg_replace help
        80260 by: Gaylen Fraley
        80263 by: mike cullerton

ENUM COL to php
        80261 by: Mehmet Kamil ERISEN
        80264 by: Jason Wong

ask cookies
        80262 by: gendeng

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


on linux, you could simply open these 'files':

/dev/stdin
/dev/stdout

for windows, and for portability, PHP provides the following dummy's,
which can also simply be used by fopen() :

php://stdin
php://stdout


bvr.



On Fri, 11 Jan 2002 12:19:05 -0500, Mullin, Reginald wrote:

>Hi Guys,
>I recently read an email entitled "Can a PHP program receive an e-mail and
>write it to a file???" in the PHP archives (see
>http://marc.theaimsgroup.com/?l=php-general&m=97986044121868&w=2) and wanted
>to ask a follow up question.  I'm a novice programmer, new to PHP, and
>unfamiliar with the ways in which to access the Standard Input for a PHP
>program.  Can anyone provide me with some examples or online reference
>material as to how I can go about doing this.  For example, is there a
>particular variable or function that I should call?  Or, is there something
>that needs to be initialized?
>P.S.  Thanks, in advance, for all of your help and assistance. 
>
>O      From Now 'Till Then,
>\->    Reginald Alex Mullin
>/\      More Questions than Answers
>
>
>
>**********************************************************************
>This email and any files transmitted with it are confidential and
>intended solely for the use of the individual or entity to whom they
>are addressed. If you have received this email in error please notify
>the postmaster at [EMAIL PROTECTED]
>
>
>www.sothebys.com
>**********************************************************************
>
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>



--- End Message ---
--- Begin Message ---
> Hi Guys,
> 
> I've written the following program to write an email from PHP Standard
> Input to an html file:
> 
> **************************************************************************
> ***
> <?php
> $file = "php://stdin";
> $fp = @fopen($file,"rb");
> if ($fp){
>       $contents = fread($fp,filesize($file));
>       $fw = @fopen ("/www/htdocs/pgs/htm/stdin.htm", "wb+");
>               if ($fw){
>                       flock($fw, 1);
>                       fwrite($fw, $contents, filesize($file));
>                       fclose($fw);
>               } else {
>                       print "The file stdin.htm does not exist!";
>               } 
>       @fclose($fp);
> } else {
>       print "The file php://stdin does not exist!";
> }
> ?>
> **************************************************************************
> ***
> 
> However, whenever the email attempts to access the program, the
> mailer-daemon returns the following error message:
> 
> **************************************************************************
> ***
> The original message was received at Fri, 11 Jan 2002 15:01:34 -0500
> from [63.105.171.52]
> 
>    ----- The following addresses had permanent fatal errors -----
> "|php -q /www/htdocs/exe/php/Email2MySql.php"
>     (expanded from: <[EMAIL PROTECTED]>)
> 
>    ----- Transcript of session follows -----
> sh: php: command not found
> 554 "|php -q /www/htdocs/exe/php/Email2MySql.php"... unknown mailer error
> 127
> **************************************************************************
> ***
> 
> What am I doing wrong here?  Did I screw up the alias?  Does my system not
> support this functionality?  HELP.
> 
> P.S.  My virtual server is running Linux.
> 
> 
> 
> O      From Now 'Till Then,
> \->    Reginald Alex Mullin
> /\      212-894-1690
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, January 11, 2002 12:30 PM
> To:   [EMAIL PROTECTED]; Mullin, Reginald
> Subject:      Re: [PHP] Using PHP to post the contents of an email to
> MySql database
> 
> 
> 
> on linux, you could simply open these 'files':
> 
> /dev/stdin
> /dev/stdout
> 
> for windows, and for portability, PHP provides the following dummy's,
> which can also simply be used by fopen() :
> 
> php://stdin
> php://stdout
> 
> 
> bvr.
> 
> 
> 
> On Fri, 11 Jan 2002 12:19:05 -0500, Mullin, Reginald wrote:
> 
> >Hi Guys,
> >I recently read an email entitled "Can a PHP program receive an e-mail
> and
> >write it to a file???" in the PHP archives (see
> >http://marc.theaimsgroup.com/?l=php-general&m=97986044121868&w=2) and
> wanted
> >to ask a follow up question.  I'm a novice programmer, new to PHP, and
> >unfamiliar with the ways in which to access the Standard Input for a PHP
> >program.  Can anyone provide me with some examples or online reference
> >material as to how I can go about doing this.  For example, is there a
> >particular variable or function that I should call?  Or, is there
> something
> >that needs to be initialized?
> >P.S.  Thanks, in advance, for all of your help and assistance. 
> >
> >O      From Now 'Till Then,
> >\->    Reginald Alex Mullin
> >/\      More Questions than Answers
> >
> >
> >
> >**********************************************************************
> >This email and any files transmitted with it are confidential and
> >intended solely for the use of the individual or entity to whom they
> >are addressed. If you have received this email in error please notify
> >the postmaster at [EMAIL PROTECTED]
> >
> >
> >www.sothebys.com
> >**********************************************************************
> >
> >
> >-- 
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the postmaster at [EMAIL PROTECTED]


www.sothebys.com
**********************************************************************

--- End Message ---
--- Begin Message ---
Hi there, I have a db with only one table in it called "CONSULTANT". I'm
using sqlServer and would like to do record paging, say 5 at a time. I'm
aware that sqlServer doesn't support the LIMIT statement so I've decided to
do it using arrays.

So I've written the appropriate query statement, managed to grab details for
each consultant and dump that array into a new array called
$consultantarray.

Now, what I'd like to be able to do is this...return 5 records at a time.
Have 2 links called "next" and "previous" that when clicked adjusts the
$consultantarray accordingly.

Can someone take a look at my code below and tell me where I have to go from
here. So far the arrays are fine (meaning they are holding the appropriate
values), just the display of the appropriate records from the array is my
big problemo. :) I currently have a foreach loop being used, but am unsure
if this is the correct route to take, in fact, I know this isn't right
because it's displaying the records oddly.

Thx for your help, Joe :)


   <?php

#connect to db
$connectionToDB = odbc_connect("cdxcet", "joecqon", "joecoqdsn");

#create query statement
$sqls = "SELECT consultantid, firstname, lastname, city, stateprovince,
country, category, yearsexp FROM CONSULTANT WHERE category ='$category'
ORDER BY yearsexp DESC" ;

#execute the sql statement (query) on the connection made
$resultset = odbc_do($connectionToDB, $sqls);


print "<h4 align='left'><font color='#663399' face='verdana'>Consultant
Search Results for: " . $category . "</font></h4>";
#print out results here
#start the table -- loop through rows below
print "<table width='740' cellpadding='5' cellspacing='0' border='0'>";
print "<tr><td align='left' width='230'><font color='#663399'
face='verdana'><b>Name</b></font></td><td align='left' width='200'><b><font
color='#663399' face='verdana'>City</font></b></td><td align='left'
width='200'><b><font color='#663399'
face='verdana'>State/Province</font></b></td><td align='left'
width='200'><b><font color='#663399'
face='verdana'>Country</font></b></td><td align='left' width='200'><b><font
color='#663399' face='verdana'>Category</font></b></td><td align='left'
width='200'><b><font color='#663399' face='verdana'>Years
Exp</font></b></td></tr>";
print "<tr><td height=10></td><td></td><td></td></tr>";


#initialize the consultant details array
$consultantdetailsarray[] = array();

// fetch the data from the database
while(odbc_fetch_row($resultset)){

  $consultantdetailsarray[0] = odbc_result($resultset, 1);
  $consultantdetailsarray[1] = odbc_result($resultset, 2);
  $consultantdetailsarray[2] = odbc_result($resultset, 3);
  $consultantdetailsarray[3] = odbc_result($resultset, 4);
  $consultantdetailsarray[4] = odbc_result($resultset, 5);
  $consultantdetailsarray[5] = odbc_result($resultset, 6);
  $consultantdetailsarray[6] = odbc_result($resultset, 7);
  $consultantdetailsarray[7] = odbc_result($resultset, 8);




#dump each consultant into the new array called $consultantarray
  $consultantarray[] = $consultantdetailsarray;
}
 #forloop to iterate through array of consultants



foreach ($consultantarray as $value){
  $cid = $consultantdetailsarray[0];
  $firstname = $consultantdetailsarray[1];
  $lastname = $consultantdetailsarray[2];
  $city = $consultantdetailsarray[3];
  $stateprovince = $consultantdetailsarray[4];
  $country = $consultantdetailsarray[5];
  $category = $consultantdetailsarray[6];
  $yearsexp = $consultantdetailsarray[7];

print "<tr><td align=left><font color='#663399' face='verdana' size=2><a
href='consultantdetails.php?cid=" . $cid . "'>"  . $firstname . " " .
$lastname . "</a></font></td><td align=left><font color='#663399'
face='verdana' size=2>" . $city . "</font></td><td align=left><font
color='#663399' face='verdana' size=2>" . $stateprovince . "</font></td><td
align=left><font color='#663399' face='verdana' size=2>" . $country .
"</font></td><td align=left><font color='#663399' face='verdana' size=2>" .
$category . "</font></td><td align=left><font color='#663399' face='verdana'
size=2>" . $yearsexp . "</font></td></tr>";
}



print "</table><br><br>";

print "The count of the consultant array elements is : " .
count($consultantdetailsarray) . "<BR>";
print "The record count of returned consultants according to category
selected is : " . sizeof($consultantarray) . "<BR>";



  // close the connection
odbc_close($connectionToDB);


   ?>


--- End Message ---
--- Begin Message ---
> what function is used to remove an array element from an array?  Like
> array_pop(), except one by which I can refer to the element by its
> associative index rather than just the last element of the array.

   unset($array['index']);

>      echo "<select name=\"home_div_id\">\n";
>      echo "<option value=\"$home_div_id\"
> selected=\"yes\">$div_name</option>\n";
>      while ($temprow = mysql_fetch_array($tempresult)) {
>          echo "<option value=\"" . $temprow['div_id']
>                . "\">" . $temprow['div_name'] . "</option>\n";
>      }
>      echo "</select>\n";

Why not just add a simple check inside that while loop?

   if($temprow['div_id'] != $home_div_id)
      echo "<option value=\"" . $temprow['div_id']
          . "\">" . $temprow['div_name'] . "</option>\n";


Seems more logical to me than to mess with the array itself.

-Rasmus

--- End Message ---
--- Begin Message ---
Erik Price wrote:

> what function is used to remove an array element from an array?  Like 
> array_pop(), except one by which I can refer to the element by its 
> associative index rather than just the last element of the array.



> 
> 
> For more detail with what I'm doing, I have two versions of a <select> 
> listbox -- one that includes an <option> with selected="yes" (if the 
> user is calling this page from submitting a form).  The other version is 
> for users who are NOT calling this page from submitting a form, i.e. for 
> the first time.
> 
> I would like, in the first version (if ($formfilled)), to REMOVE the 
> element $temprow['div_name'] from the array $temprow so that it doesn't 
> appear a second time (in the WHILE loop), since it has already been 
> echoed above the WHILE loop.
> 
> Is this even possible?



I would do it another way.

say you have all the possible choices in an array that come out of a 
database, and ypou want, if the user already selected one, this one to 
be selected, right?
Then i would set the selected atribute only if the value out of the 
database is the same as the one submitted by the form:

like this (omitting the surrounding html):

$query= "select distinct * from sometable";

$result=mysql_query($query);

// the select field is named selectfield,

echo "<form name=\"myform\" action=\"$PHP_SELF\" Method=\"post\">";
echo "<select name=\"selectfield\">";

// the variable $selectfield is, if set the value submitted by the form
$selectfield = $_POST["selectfield"];

while ($row=mysql_fetch_array($result)){
        echo "<option";
        // assuming the second element of this array holds your         
        // choices then
        if($selectfield == $row[1]){
                echo " selected";
        }
        echo ">" . $row[1] . "</option>\n";
}
echo "</select>"

echo "<input type=\"submit\">\n";
echo "</form>";


                
        
i think this is a more straightforward solution for your problem...


henning








--- End Message ---
--- Begin Message ---
Because, as a dope, I forget that you can invert IF statements like 
that -- you're right, I'd rather do that than mess with the array.

Although the feedback on unset($arrayname['index']) was extremely useful 
knowledge!  Thank you everyone.

Erik


On Friday, January 11, 2002, at 12:31  PM, Rasmus Lerdorf wrote:

> Why not just add a simple check inside that while loop?
>
>    if($temprow['div_id'] != $home_div_id)
>       echo "<option value=\"" . $temprow['div_id']
>           . "\">" . $temprow['div_name'] . "</option>\n";
>
>
> Seems more logical to me than to mess with the array itself.
>
> -Rasmus
>

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


It happens a lot here that people ask questions that could easily be found
by browsing the manual or searching the PHP FAQ and website.

Some people really should read the FAQ and manual (php.net) when they have a 
question and preferrably search an archive of this list (deja.com).

It really won't hurt to at least check those first chapters of the manual, so
you know what answers you can find there.

Also, a searchengine (google.com)  can answer almost any programming question. 

This would save the people on this list much time reading messages,
answering (or referring to the FAQ, manual or previous posts) and will
ultimately save yourself some time waiting for replies.


bvr.


--- End Message ---
--- Begin Message ---
On Saturday 12 January 2002 01:49, [EMAIL PROTECTED] wrote:
> It happens a lot here that people ask questions that could easily be found
> by browsing the manual or searching the PHP FAQ and website.
>
> Some people really should read the FAQ and manual (php.net) when they have
> a question and preferrably search an archive of this list (deja.com).
>
> It really won't hurt to at least check those first chapters of the manual,
> so you know what answers you can find there.
>
> Also, a searchengine (google.com)  can answer almost any programming
> question.
>
> This would save the people on this list much time reading messages,
> answering (or referring to the FAQ, manual or previous posts) and will
> ultimately save yourself some time waiting for replies.

May I add that using an appropriate and descriptive subject text would 
increase the chances of questions being read and answered. It also helps 
others who may be having similar problems to easily determine which posts 
they should be reading.

Subjects like:

"Quick question"
"Please help!!!"

etc usually find their way into my trashcan without being read :)


my tuppence
-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Type louder, please.
*/
--- End Message ---
--- Begin Message ---
one of my biggest problems, which happens here a lot, is that some people
will ask a completely different question (with a different topic header)
under an existing thread rather than starting a new thread. all it takes is
a few minutes to familiarize oneself with the newsreader, but apparently a
few minutes is too much..

[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


--- End Message ---
--- Begin Message ---
Many people use mail clients that don't do any sort of threading to follow 
what's going on on this list; I use Eudora, personally, when in Windows, 
and the Mozilla mail client when I'm in Linux.  It was, quite literally, 
years before someone finally pointed out to me that in a mail reader or a 
news reader that supports threading, if I start a new thread I shouldn't 
reply to an old thread with a new subject line.  I'm now very careful to 
follow that procedure.  In my mail client, it makes no difference, but I 
know it affects other readers.

That's just why it happens; because not everyone uses a newsreader to read 
this newsgroup, so many people don't even realize what's happening.

At 11:22 AM 1/11/2002, l0t3k wrote:
>one of my biggest problems, which happens here a lot, is that some people
>will ask a completely different question (with a different topic header)
>under an existing thread rather than starting a new thread. all it takes is
>a few minutes to familiarize oneself with the newsreader, but apparently a
>few minutes is too much..


Sliante,
Richard S. Crawford

http://www.mossroot.com
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
MSN: [EMAIL PROTECTED]

"It is only with the heart that we see rightly; what is essential is 
invisible to the eye."  --Antoine de Saint Exupéry

"Push the button, Max!"

--- End Message ---
--- Begin Message ---
> > $sql = "SELECT * FROM tablename WHERE 
> > tablename.column=$_GET['criteria_integer']";
> > 
> > but unfortunately, this isn't working.

On a related note, outside of strings one should always surround keys with
quotes, so:

  $arr = array('a' => 'apple', 'b' => 'banana');

  print $arr['a']; // apple
  print $arr[a];   // apple BUT this is bad

Without the quotes is bad because PHP first:

  a) looks for the constant named 'a'
  b) if constant 'a' is not found, an error of type 
     E_NOTICE is thrown.

So, let's do this:

  define('a','b');

  print $arr['a']; // apple
  print $arr[a];   // banana (no error)

Because constants are not looked for within strings, the following is
appropriate:

  print "an $arr[a]";     // an apple

As are:

  print "an {$arr['a']}"; // an apple
  print "an ". $arr['a']; // an apple

Anyway, maybe that helps explain a few things :)

Regards,
Philip Olson

--- End Message ---
--- Begin Message ---
It seems that you are saying that not using quotes is bad (first), but 
then later you show that omitting the quotes does not result in an error.
Or are you saying that the quotes can be omitted if the array element is 
being used in a string (between quotes), but generally the quotes around 
the constant are needed to perform non-string operations?

Thank you,
Erik



On Friday, January 11, 2002, at 01:06  PM, Philip Olson wrote:

>>> $sql = "SELECT * FROM tablename WHERE
>>> tablename.column=$_GET['criteria_integer']";
>>>
>>> but unfortunately, this isn't working.
>
> On a related note, outside of strings one should always surround keys 
> with
> quotes, so:
>
>   $arr = array('a' => 'apple', 'b' => 'banana');
>
>   print $arr['a']; // apple
>   print $arr[a];   // apple BUT this is bad
>
> Without the quotes is bad because PHP first:
>
>   a) looks for the constant named 'a'
>   b) if constant 'a' is not found, an error of type
>      E_NOTICE is thrown.
>
> So, let's do this:
>
>   define('a','b');
>
>   print $arr['a']; // apple
>   print $arr[a];   // banana (no error)
>
> Because constants are not looked for within strings, the following is
> appropriate:
>
>   print "an $arr[a]";     // an apple
>
> As are:
>
>   print "an {$arr['a']}"; // an apple
>   print "an ". $arr['a']; // an apple
>
> Anyway, maybe that helps explain a few things :)
>
> Regards,
> Philip Olson
>

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

Hi again Michael:

Digging documentation I found out that this behaviour (string and int keys)
is native for mysql_fetch_arrow() (found into the help: 'In addition to
storing the data in the numeric indices of the result array, it also stores
the data in associative indices, using the field names as keys. ')

So the question is answered. Thank you for your help.

Best regards

Ivo


"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 09:18 PM 1/10/2002 +0100, Ivo Stoykov wrote:
> >How could I determine whether I have in the array's key integers *and*
> >strings or integers only?
>
> I'm not sure exactly what you're asking but I'll give it a shot...
>
> >i.e.
> >$a = new array('one', 'two', 'three'); // this has only integers (am I
> >wrong?)
>
> First of all, the "new" keyword assumes that you are instantiating an
> object.  For example if you created an object with the name foo you would
> instantiate it like so:
>
> $a = new foo;
>
> So when creating arrays the "new" keyword is undesirable.
>
> To address your question, yes your example above (after removing the "new"
> keyword) will create an array named $a that has only integers for
> keys.  It's functionally the same as this:
>
> $a = array(0 => 'one', 1 => 'two', 2 => 'three');
>
> >$b = new array('one' => 'bla', 'two' => 'blabla', 'three' =>
'blablabla');
> >// integers & strings
>
> The above example (again once corrected to remove the "new" keyword) will
> create an array named $b that has ONLY strings for keys.  There are no
keys
> that are integers because you didn't create any.  You can test this by
> trying to echo the values out by key:
>
> echo $b['one']; //outputs "bla"
> echo $b[0]; //outputs nothing because this key does not have a value.
>
> This is perfectly legal:
>
> $b = array ('one' => 'bla', 'two' => 'blabla', 'three' => 'blablabla', 0
=>
> 'blablablabla',
> 1 => 'blablablablabla');
>
> In the above case you do have some keys that are strings and some that are
> integers but they are DIFFERENT keys, representing DIFFERENT values.
>
> Hope that answers your question...
>


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

Hi again Michael:

Digging documentation I found out that this behaviour (string and int keys)
is native for mysql_fetch_arrow() (found into the help: 'In addition to
storing the data in the numeric indices of the result array, it also stores
the data in associative indices, using the field names as keys. ')

So the question is answered. Thank you for your help.

Best regards

Ivo


"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 09:18 PM 1/10/2002 +0100, Ivo Stoykov wrote:
> >How could I determine whether I have in the array's key integers *and*
> >strings or integers only?
>
> I'm not sure exactly what you're asking but I'll give it a shot...
>
> >i.e.
> >$a = new array('one', 'two', 'three'); // this has only integers (am I
> >wrong?)
>
> First of all, the "new" keyword assumes that you are instantiating an
> object.  For example if you created an object with the name foo you would
> instantiate it like so:
>
> $a = new foo;
>
> So when creating arrays the "new" keyword is undesirable.
>
> To address your question, yes your example above (after removing the "new"
> keyword) will create an array named $a that has only integers for
> keys.  It's functionally the same as this:
>
> $a = array(0 => 'one', 1 => 'two', 2 => 'three');
>
> >$b = new array('one' => 'bla', 'two' => 'blabla', 'three' =>
'blablabla');
> >// integers & strings
>
> The above example (again once corrected to remove the "new" keyword) will
> create an array named $b that has ONLY strings for keys.  There are no
keys
> that are integers because you didn't create any.  You can test this by
> trying to echo the values out by key:
>
> echo $b['one']; //outputs "bla"
> echo $b[0]; //outputs nothing because this key does not have a value.
>
> This is perfectly legal:
>
> $b = array ('one' => 'bla', 'two' => 'blabla', 'three' => 'blablabla', 0
=>
> 'blablablabla',
> 1 => 'blablablablabla');
>
> In the above case you do have some keys that are strings and some that are
> integers but they are DIFFERENT keys, representing DIFFERENT values.
>
> Hope that answers your question...
>


--- End Message ---
--- Begin Message ---
Hi again Michael:

Digging documentation I found out that this behaviour (string and int keys)
is native for mysql_fetch_arrow() (found into the help: 'In addition to
storing the data in the numeric indices of the result array, it also stores
the data in associative indices, using the field names as keys. ')

So the question is answered. Thank you for your help.

Best regards

Ivo


"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 09:18 PM 1/10/2002 +0100, Ivo Stoykov wrote:
> >How could I determine whether I have in the array's key integers *and*
> >strings or integers only?
>
> I'm not sure exactly what you're asking but I'll give it a shot...
>
> >i.e.
> >$a = new array('one', 'two', 'three'); // this has only integers (am I
> >wrong?)
>
> First of all, the "new" keyword assumes that you are instantiating an
> object.  For example if you created an object with the name foo you would
> instantiate it like so:
>
> $a = new foo;
>
> So when creating arrays the "new" keyword is undesirable.
>
> To address your question, yes your example above (after removing the "new"
> keyword) will create an array named $a that has only integers for
> keys.  It's functionally the same as this:
>
> $a = array(0 => 'one', 1 => 'two', 2 => 'three');
>
> >$b = new array('one' => 'bla', 'two' => 'blabla', 'three' =>
'blablabla');
> >// integers & strings
>
> The above example (again once corrected to remove the "new" keyword) will
> create an array named $b that has ONLY strings for keys.  There are no
keys
> that are integers because you didn't create any.  You can test this by
> trying to echo the values out by key:
>
> echo $b['one']; //outputs "bla"
> echo $b[0]; //outputs nothing because this key does not have a value.
>
> This is perfectly legal:
>
> $b = array ('one' => 'bla', 'two' => 'blabla', 'three' => 'blablabla', 0
=>
> 'blablablabla',
> 1 => 'blablablablabla');
>
> In the above case you do have some keys that are strings and some that are
> integers but they are DIFFERENT keys, representing DIFFERENT values.
>
> Hope that answers your question...
>


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

Hi again Michael:

Digging documentation I found out that this behaviour (string and int keys)
is native for mysql_fetch_arrow() (found into the help: 'In addition to
storing the data in the numeric indices of the result array, it also stores
the data in associative indices, using the field names as keys. ')

So the question is answered. Thank you for your help.

Best regards

Ivo
"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 09:18 PM 1/10/2002 +0100, Ivo Stoykov wrote:
> >How could I determine whether I have in the array's key integers *and*
> >strings or integers only?
>
> I'm not sure exactly what you're asking but I'll give it a shot...
>
> >i.e.
> >$a = new array('one', 'two', 'three'); // this has only integers (am I
> >wrong?)
>
> First of all, the "new" keyword assumes that you are instantiating an
> object.  For example if you created an object with the name foo you would
> instantiate it like so:
>
> $a = new foo;
>
> So when creating arrays the "new" keyword is undesirable.
>
> To address your question, yes your example above (after removing the "new"
> keyword) will create an array named $a that has only integers for
> keys.  It's functionally the same as this:
>
> $a = array(0 => 'one', 1 => 'two', 2 => 'three');
>
> >$b = new array('one' => 'bla', 'two' => 'blabla', 'three' =>
'blablabla');
> >// integers & strings
>
> The above example (again once corrected to remove the "new" keyword) will
> create an array named $b that has ONLY strings for keys.  There are no
keys
> that are integers because you didn't create any.  You can test this by
> trying to echo the values out by key:
>
> echo $b['one']; //outputs "bla"
> echo $b[0]; //outputs nothing because this key does not have a value.
>
> This is perfectly legal:
>
> $b = array ('one' => 'bla', 'two' => 'blabla', 'three' => 'blablabla', 0
=>
> 'blablablabla',
> 1 => 'blablablablabla');
>
> In the above case you do have some keys that are strings and some that are
> integers but they are DIFFERENT keys, representing DIFFERENT values.
>
> Hope that answers your question...
>


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

Hi again Michael:

Digging documentation I found out that this behaviour (string and int keys)
is native for mysql_fetch_arrow() (found into the help: 'In addition to
storing the data in the numeric indices of the result array, it also stores
the data in associative indices, using the field names as keys. ')

So the question is answered. Thank you for your help.

Best regards

Ivo
"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 09:18 PM 1/10/2002 +0100, Ivo Stoykov wrote:
> >How could I determine whether I have in the array's key integers *and*
> >strings or integers only?
>
> I'm not sure exactly what you're asking but I'll give it a shot...
>
> >i.e.
> >$a = new array('one', 'two', 'three'); // this has only integers (am I
> >wrong?)
>
> First of all, the "new" keyword assumes that you are instantiating an
> object.  For example if you created an object with the name foo you would
> instantiate it like so:
>
> $a = new foo;
>
> So when creating arrays the "new" keyword is undesirable.
>
> To address your question, yes your example above (after removing the "new"
> keyword) will create an array named $a that has only integers for
> keys.  It's functionally the same as this:
>
> $a = array(0 => 'one', 1 => 'two', 2 => 'three');
>
> >$b = new array('one' => 'bla', 'two' => 'blabla', 'three' =>
'blablabla');
> >// integers & strings
>
> The above example (again once corrected to remove the "new" keyword) will
> create an array named $b that has ONLY strings for keys.  There are no
keys
> that are integers because you didn't create any.  You can test this by
> trying to echo the values out by key:
>
> echo $b['one']; //outputs "bla"
> echo $b[0]; //outputs nothing because this key does not have a value.
>
> This is perfectly legal:
>
> $b = array ('one' => 'bla', 'two' => 'blabla', 'three' => 'blablabla', 0
=>
> 'blablablabla',
> 1 => 'blablablablabla');
>
> In the above case you do have some keys that are strings and some that are
> integers but they are DIFFERENT keys, representing DIFFERENT values.
>
> Hope that answers your question...
>


--- End Message ---
--- Begin Message ---
quiero conectarme con un servidor sql server 2000
y hasta ahora no he podido. lo intentado con la funcion mssql_connect("server name", 
"user name", "contraseña")
y en el browser recibo el siguiente mensaje 
Fatal error: Call to undefined function: mssql_connect() in 
c:\inetpub\wwwroot\receve\prueba.php

alguien puede guiarme se lo agradeceria

----------------------------------------------------------------------------------------
i wanna to connect to sql server 2000 and i can not.
i try with the function of mssql' s library mssql_connect("server name", "user name", 
"contraseña") and not have good results

Do Help me somebody? I need it very much
thanks for all



--- End Message ---
--- Begin Message ---
Hola !!!
Tienes que ins.... oh, sorry. ;-))

You need to install MsSQL support for PHP, by getting the right PHP module 
and adding it in your 'php.ini' file .... see this file for the exact syntax.

Hasta la vista ...

Le Vendredi 11 Janvier 2002 19:14, vania a écrit :
> quiero conectarme con un servidor sql server 2000
> y hasta ahora no he podido. lo intentado con la funcion
> mssql_connect("server name", "user name", "contraseña") y en el browser
> recibo el siguiente mensaje
> Fatal error: Call to undefined function: mssql_connect() in
> c:\inetpub\wwwroot\receve\prueba.php
>
> alguien puede guiarme se lo agradeceria
>
> ---------------------------------------------------------------------------
>------------- i wanna to connect to sql server 2000 and i can not.
> i try with the function of mssql' s library mssql_connect("server name",
> "user name", "contraseña") and not have good results
>
> Do Help me somebody? I need it very much
> thanks for all

-- 
 ( * >    Nicolas Costes,
 //\\      IUT de La Roche / Yon, poste 8449
( \/ )     [EMAIL PROTECTED]
 < <      http://luxregina.free.fr
--- End Message ---
--- Begin Message ---
Ben Clumeck wrote:

> When using MySQL to Authenticate users for a specific directory (i.e.
> www.mysite.com/user) how would it know to go to that directory ("/user").

 > How would it know to not let someone access a file directory in that
 > directory (i.e. www.mysite.com/user/page2.php)?

this question is too general - you should describe your idea of what you 
want to do and where your problem is a bit more.

In general is is you who would be responsible to write the code that 
checks if a user is authenticated and should have access to something, 
and you have to include that piece of code at the beginning of each page 
you want to limit access for.


>If I am using MySQL to
> query a row in a table can how would it know to only let a specific user(s)
> have access to the information?
> 


this either a mysql related question - as mysql deals with the problem 
that a user has to be authenticated within mysql_connect or 
mysql_pconnect to access some information - or it is a matter of your 
application design - if you want only special users to do something or 
to get some views of the data you queried from mysql you can go and
create a user table with users and poasswords, and a permission table 
where users are designated to specific tasks, then, before you show some 
data in your script, you ask the user for a password, look him up in 
your users table, and only let him view the things he is allowed to.

but, again, this is a very general answer on a general question, which 
might be the reason why nobody answered until now, to get some real 
useful answers or solutions to your problem you have to be more specific.

maybe you want to go through some basic tutorials first before doing 
such comlicated things and learn the basics of php and mysql before 
playing around with big applications, permissions for users, etc...

(sorry, got no URL for something lkike this at hand now, use google)

hope this still helps

henning

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

On Friday, January 11, 2002, at 06:05  AM, Ford, Mike [LSS] wrote:

> Incidentally, I've occasionally had problems including a variable name 
> containing an underscore in a double-quoted string (e.g. "$num_recs 
> records retrieved"), where PHP tries to insert the value of $num 
> followed by the string "_recs", so I always {} those as well, just to 
> be on the safe side ("{$num_recs} ..." or "${num_recs} ..." both work.

You mentioned that {$num_recs} and ${num_recs} both work -- I'm familiar 
with the second form from bash shell scripting, but not the first.  Do 
they both work in all instances, or is one "preferred" over the other?

Thanks Mike

And sorry for making you repeat yourself (the first email I sent was 
incomplete but for some reason got sent, which you replied to and then 
the second, intended, email went out and that is when you wrote your 
second reply :).  I have a better understanding of using associative 
indexes from arrays in double-quoted statements now.

Erik

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

Hi
I built PHP on an ALPHA running OSF V5.1

I did the install after the make just like i did in the past.
This time, however, when i do:
apachectl start
i get this:
/usr/local/apache/bin/apachectl: 323331 Memory fault
/usr/local/apache/bin/apachectl start: httpd could not be started

There are no error messages being print to any apache logs.

Now, I had apache running previously with PHP. I realized that imap had
not been properly installed into my PHP so i went back and rebuilt PHP.
Now I get this problem.



This is my configuration:

./configure  --with-apxs=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql --with-gd=/usr/local/src/gd-1.8.4
--with-png-dir=/usr/local/src/libpng-1.2.0
--with-zlib-dir=/usr/local/src/zlib --with-curl=/usr/local/lib
--with-calendar --with-jpeg-dir=/usr/local/src/jpeg-6b/ --with-imap

(imap was installed by putting c-client.a in /usr/lib and the appropriate
header files in /usr/include)

This time around I had to edit a php source file:
in ext/standard/scanf.c
and make the function scan_set_error_return to NOT be an inline function.

Has any had this problem before?

thanks!
tom holton


..


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

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

Quick tip -- locate and whereis are your friends in the shell. They make 
finding executables like php are a snap.

As for emailing from php/cron, it depends on how your system is set up. 
Many email servers bounce any emails they receive from IPs that they can't 
reverse map or otherwise identify. If your machine is on a LAN for 
instance, the emails will probably get bounced.

Another thing to check is that your user account can actually use your 
system's SMTP service. Email sent with php's mail() function are usually 
sent by the owner of the script (or the web server's user). 

J



Mehmet Kamil Erisen wrote:

> hi,
> thanks for the tip.  I was wondering about it too....
> I do not have access to everywhere on the server.
> I tried /usr/bin/php and it worked...... :)
> 
> I tested the following script for connection to database,
> executing my functions etc...
> everything seems to work but mail.
> any ideas?
> 
> Thanks for the help.
> erisen
> 
> btw: at last, I added the die to my mail command, and fair
> enough, I got the Can not send this as output.
> 
> So, now the question is, how can I send mail with php /
> cron config.
> 
> please note that the script worked fine on the browser.
> thx.
> 
> code:
> #!/usr/bin/php -q
> 
> 
> <?php
> 
> include ("application.php");
> 
>         $subject="Cron Job has run";
>         $body="test.php is running now";
>         $sendtome = "[EMAIL PROTECTED]";
>         mail("[EMAIL PROTECTED]", $subject, $body,$sendtome)
> or die ('Can not send this');
>         echo $sendtome;
>         echo "hello world";
> 
> echo turk_now() ;
> 
> $array = get_user_stat($CONF) ;
> while (list($key,$value)=each($array)) {
> echo "$key $value<BR>";
> }
>        
> 
> ?>
> 
>
--- End Message ---
--- Begin Message ---
Hi Everybody,

   Has anyone doing it sucefuly? I can compile it. The phpinfo(); call
returns ok! (UCD-Snmp enable) but when I call the snmp functions I got a
SegFault (on PHP-CGI). I already tried with an without
--enable-ucd-snmp-hack, and recompiling the UCD-Snmp packages as told on
the PHP manual pages (http://www.php.net/snmp).

   Any tips on this?

                                                Thanks in advance,

                                                              Antonio. 

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Antonio S. Martins Jr. - System Analist |  "Only The Shadow Knows   |
| WorldNet Internet Maringa - PR - Brasil |   what evil lurks in the  |
| E-Mail: [EMAIL PROTECTED]              |       Heart of Men!"      |
|         [EMAIL PROTECTED]                   | !!! Linux User: 52392 !!! |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
               This e-mail message is 100% Microsoft free!

                         /"\
                         \ /  CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
                          X   ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
                         / \




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

I am currently developing a site which makes use of SSL and sessions.
However, sometimes when I submit
form data (from an SSL page to another SSL page on the same server), I get
an error saying "This page
contains both secure and unsecure items. Do you want to display the
nonsecure items" (I have had these
results in IE5.5 and IE6, possibly IE5 too). If I press yes, a DNS error
page appears. If i press no,
a page saying simply "NavigationCancelled" (without any spaces) appears.
This error seems to happen
randomly, and only when form data is being sent with POST (I haven't tried
it with GET or anything else
as it may be a security risk to have the form contents displayed in the
query string).

I have found a way to fix this, however, it had some undesirable affects
with pages being cashed (and
therefore not being displayed with any changed session variables). This
"fix" was done using session_cache_limiter('private'),
but I don't want to use this due to these caching effects.

Does anyone have any suggestions that could fix this problem? I would be
very grateful.

Richard Hilton



--- End Message ---
--- Begin Message ---
Well, I did not configure it any particular way.

I just tried to build the mod_php4 port on FreeBSD.  I assumed it would
work.  Why would the FreeBSD port developers commit something to the stable
release that doesn't work?

Thanks,
Brian

"Brian Clark" <[EMAIL PROTECTED]> wrote in message
20020110230835.GA1557@ganymede">news:20020110230835.GA1557@ganymede...
> * Brian Williams ([EMAIL PROTECTED]) [Jan 10. 2002
04:57]:
>
> > Hi All,
>
> Hello
>
> > When I try to run apache, I get this error message:
>
> > Cannot load /usr/local/libexec/apache/libphp4.so into server:
> > /usr/local/libexec/apache/libphp4.so:  Undefined symbol
'iconv_module_entry'
>
> So you configured PHP --with-iconv? My guess is that you'll need to
> include the path to your libraries for iconv in /etc/ld,so.conf then run
> ldconfig.
>
> --
> Brian Clark | Avoiding the general public since 1805!
> Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
> Too many freaks, and not enough circuses.
>


--- End Message ---
--- Begin Message ---
> So you configured PHP --with-iconv? My guess is that you'll need to
> include the path to your libraries for iconv in /etc/ld,so.conf then run
> ldconfig.

I do not have /etc/ld.so.conf on my system, but I do have
/usr/compat/linux/etc/ld.so.conf

Thanks,
Brian



--- End Message ---
--- Begin Message ---
* Brian Williams ([EMAIL PROTECTED]) [Jan 11. 2002 16:46]:

> > So you configured PHP --with-iconv? My guess is that you'll need to
> > include the path to your libraries for iconv in /etc/ld,so.conf then run
> > ldconfig.

> I do not have /etc/ld.so.conf on my system, but I do have
> /usr/compat/linux/etc/ld.so.conf

I think FreeBSD uses rc.conf - check the shlib_dirs variable, IIRC.

And a note about your earlier reply in this thread: I'm only guessing
this will fix the problem. That's been the fix when I've seen error
messages like that in the past when trying to load mod_php.

-- 
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Freedoms precious metals, gold, silver and lead.

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

I am rather new to PHP so I hope somebody can help me.

I have a normal button (HTML code). Then I have made a function

function multiply($X)
{
    return 2*$X;
}

The button has an OnClick, which calls my function.
<INPUT TYPE="BUTTON" name="HH" value="Mul" onClick="<? $XX=multiply(5);?>" >

I then writes $X to the screen.

<?php echo $X ?>

The problem is I dont even have to press the button. When the page loads it
already has calculated 2*$X. Why is that. I would like to only call my
function when I press my button.

Please help
Morten


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

PHP is a server-side language (i.e. Perl when used with mod_perl), not a 
client-side language (i.e. JavaScript). All of the processing is done on 
the server BEFORE it is sent to the user. Therefore, you can't call a PHP 
function directly from a web page after the user has received it, since all 
of the processing has already been done.

J


Morten Nielsen wrote:

> Hi,
> 
> I am rather new to PHP so I hope somebody can help me.
> 
> I have a normal button (HTML code). Then I have made a function
> 
> function multiply($X)
> {
>     return 2*$X;
> }
> 
> The button has an OnClick, which calls my function.
> <INPUT TYPE="BUTTON" name="HH" value="Mul" onClick="<? $XX=multiply(5);?>"
> >
> 
> I then writes $X to the screen.
> 
> <?php echo $X ?>
> 
> The problem is I dont even have to press the button. When the page loads
> it already has calculated 2*$X. Why is that. I would like to only call my
> function when I press my button.
> 
> Please help
> Morten

--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* On 11-01-02 at 22:48 
* Morten Nielsen said....

> Hi,
> 
> I am rather new to PHP so I hope somebody can help me.
> 
> I have a normal button (HTML code). Then I have made a function
> 
> function multiply($X)
> {
>     return 2*$X;
> }
> 
> The button has an OnClick, which calls my function.
> <INPUT TYPE="BUTTON" name="HH" value="Mul" onClick="<? $XX=multiply(5);?>" >
> 
> I then writes $X to the screen.
> 
> <?php echo $X ?>
> 
> The problem is I dont even have to press the button. When the page loads it
> already has calculated 2*$X. Why is that. I would like to only call my
> function when I press my button.

What value is it returning 5, or 10?

Nick Wilson

Tel:    +45 3325 0688
Fax:    +45 3325 0677
Web:    www.explodingnet.com



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8P2ArHpvrrTa6L5oRAhPjAJ9Mv4k54bNNtu8DLGBegiD7SaQA1QCggJNl
PolIOd8coSStooSyW/mmtk0=
=MNoe
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* On 11-01-02 at 22:57 
* J Smith said....

> 
> PHP is a server-side language (i.e. Perl when used with mod_perl), not a 
> client-side language (i.e. JavaScript). All of the processing is done on 
> the server BEFORE it is sent to the user. Therefore, you can't call a PHP 
> function directly from a web page after the user has received it, since all 
> of the processing has already been done.

Of course, I think in my case the expresion is 'barking up the wrong
tree'.
- -- 

Nick Wilson

Tel:    +45 3325 0688
Fax:    +45 3325 0677
Web:    www.explodingnet.com



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8P2CdHpvrrTa6L5oRAuYZAKCVRqP6XhhLIu4X2b8+xL8ctnG+SwCff+v2
As7/xKIhSyk2niDW1aLgA40=
=jQmN
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
PHP is entirely server-based.  So when you load this page into your 
browser, all of the PHP is being parsed BEFORE it ever loads into the 
browser.  So the function will be executed even before the page loads.

Do it in JavaScript if you want it to be done in the browser.  What you 
have written down will show up in the source code of your browser as:

<INPUT TYPE="BUTTON" NAME="HH" value="Mul" onClick="1">

(or something like that).

PHP runs entirely on the 
server.  Server!  Server!  Server!  Server!  Honest, I promise that it 
doesn't get interpreted by the browser.  If you have any doubts, try 
writing a PHP script, reading it in your browser, and then viewing the 
source code to see what gets rendered.

For browser-side scripting, I suggest you pick up a book on JavaScript 
programming.  Nothing you do in PHP will ever be interpreted by a browser.


At 01:59 PM 1/11/2002, Nick Wilson wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>* On 11-01-02 at 22:48
>* Morten Nielsen said....
>
> > Hi,
> >
> > I am rather new to PHP so I hope somebody can help me.
> >
> > I have a normal button (HTML code). Then I have made a function
> >
> > function multiply($X)
> > {
> >     return 2*$X;
> > }
> >
> > The button has an OnClick, which calls my function.
> > <INPUT TYPE="BUTTON" name="HH" value="Mul" onClick="<? 
> $XX=multiply(5);?>" >
> >
> > I then writes $X to the screen.
> >
> > <?php echo $X ?>
> >
> > The problem is I dont even have to press the button. When the page loads it
> > already has calculated 2*$X. Why is that. I would like to only call my
> > function when I press my button.
>
>What value is it returning 5, or 10?
>
>Nick Wilson
>
>Tel:    +45 3325 0688
>Fax:    +45 3325 0677
>Web:    www.explodingnet.com
>
>
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.0.6 (GNU/Linux)
>Comment: For info see http://www.gnupg.org
>
>iD8DBQE8P2ArHpvrrTa6L5oRAhPjAJ9Mv4k54bNNtu8DLGBegiD7SaQA1QCggJNl
>PolIOd8coSStooSyW/mmtk0=
>=MNoe
>-----END PGP SIGNATURE-----
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


Sliante,
Richard S. Crawford

http://www.mossroot.com
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
MSN: [EMAIL PROTECTED]

"It is only with the heart that we see rightly; what is essential is 
invisible to the eye."  --Antoine de Saint Exupéry

"Push the button, Max!"

--- End Message ---
--- Begin Message ---
********************************
JAVASCRIPT VERSION
<html>
<head>
<title>mytitle</title>
<script language="JavaScript" type="text/javascript">
function multiply(x){
    var myresult = 2 * x;
    document.write(myresult);
}
</script>
</head>
<body>
<form name="myform" action="<?$PHP_SELF?>" method="POST">
    <input type="button" name="mybutton" value="myvalue" 
onClick="multiply(5)">
</form>
</body>
</html>
********************************

********************************
PHP VERSION
<html>
<head>
<title>mytitle</title>
</head>
<body>
if($mybutton){
    $myresult = 2 * $mybutton;
    print $myresult;
}else{
    print "Click the button to see what 2 mulitplied by 5 is!";
}
<form name="myform" action="<?$PHP_SELF?>" method="POST">
    <input type="button" name="mybutton" value="5" onClick="mysubmit()">
</form>
</body>
</html>
********************************

You can do it either way, don't take my code at face "value" (sorry, 
couldn't resist) I haven't tested it, but it should be enough to get you 
going. I would suggest that you use the PHP version, that way you don't 
have to worry about cross browser JavaScript compatibility.

>> > Hi,
>> >
>> > I am rather new to PHP so I hope somebody can help me.
>> >
>> > I have a normal button (HTML code). Then I have made a function
>> >
>> > function multiply($X)
>> > {
>> >     return 2*$X;
>> > }
>> >
>> > The button has an OnClick, which calls my function.
>> > <INPUT TYPE="BUTTON" name="HH" value="Mul" onClick="<? 
>> $XX=multiply(5);?>" >
>> >
>> > I then writes $X to the screen.
>> >
>> > <?php echo $X ?>
>> >
>> > The problem is I dont even have to press the button. When the page 
>> loads it
>> > already has calculated 2*$X. Why is that. I would like to only call my
>> > function when I press my button.
>>
>> What value is it returning 5, or 10?
>>
>> Nick Wilson
>>
>> Tel:    +45 3325 0688
>> Fax:    +45 3325 0677
>> Web:    www.explodingnet.com
>
>
>


--- End Message ---
--- Begin Message ---
I am curious if using the same mysql_query() function twice causes some 
kind of problem.

It seems that if I use

$result = mysql_query($sql, $db);
if (mysql_fetch_array($result)) {
     while ($row = mysql_fetch_array($result) or die("You lose.  No data 
fetched.")) {
          // print some data
          // print a simple sentence to see if the WHILE statement even 
executes
     }
} else {
     // print "No results match your criteria"
}


In this, I have used the $result variable twice.  $result is essentially 
nothing more than a mysql_query() function.  If I do the above, then the 
IF statement is true but the WHILE statement doesn't seem to produce its 
intended effect.  In other words, I get the die() message "You lose.  No 
data fetched."

This leads me to believe that I can't run two instances of mysql_query() 
or perhaps mysql_fetch_array().

Does anyone know for sure if this is the case?

Erik

--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* On 11-01-02 at 23:08 
* Erik Price said....

> I am curious if using the same mysql_query() function twice causes some 
> kind of problem.
> 
> It seems that if I use
> 
> $result = mysql_query($sql, $db);
> if (mysql_fetch_array($result)) {
>     while ($row = mysql_fetch_array($result) or die("You lose.  No data 
> fetched.")) {
>          // print some data
>          // print a simple sentence to see if the WHILE statement even 
> executes
>     }
> } else {
>     // print "No results match your criteria"
> }
> 
> 
> IF statement is true but the WHILE statement doesn't seem to produce its 
> intended effect.  In other words, I get the die() message "You lose.  No 
> data fetched."

I'll most likely be corrected (I just joined the list to brush up on my
php) but I think that if you change this 

>     while ($row = mysql_fetch_array($result) or die("You lose.  No data 

to this

>     while ($row = mysql_fetch_array($another_result) or die("You lose.  No data 

You'll be on the right track.


> This leads me to believe that I can't run two instances of mysql_query() 
> or perhaps mysql_fetch_array().

No, of course you can.


HTH
- -- 

Nick Wilson

Tel:    +45 3325 0688
Fax:    +45 3325 0677
Web:    www.explodingnet.com



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8P2XjHpvrrTa6L5oRArToAJ96owiXpTmPnOGSOI2jzvMHnAwm1ACbBXk2
DbgVDF6NwxSwOA8+p86zNC0=
=0Z6i
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---

EXCELLENT!
It worked perfect.
So $result can't be used twice -- I wonder if it somehow is altered by 
the mysql_fetch_array() that is performed upon it.

Thanks Nick.

On Friday, January 11, 2002, at 05:23  PM, Nick Wilson wrote:

> I'll most likely be corrected (I just joined the list to brush up on my
> php) but I think that if you change this
>
>>     while ($row = mysql_fetch_array($result) or die("You lose.  No data
>
> to this
>
>>     while ($row = mysql_fetch_array($another_result) or die("You 
>> lose.  No data
>
> You'll be on the right track.

--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* On 11-01-02 at 23:39 
* Erik Price said....

> 
> EXCELLENT!
> It worked perfect.
> So $result can't be used twice -- I wonder if it somehow is altered by 
> the mysql_fetch_array() that is performed upon it.

That's not it. Your first $result is a resource indicator (container for
results) so if you re-assign it (put another value into it) it becomes
useless as your while statement depends on it.

Happy to help :)
- -- 

Nick Wilson

Tel:    +45 3325 0688
Fax:    +45 3325 0677
Web:    www.explodingnet.com



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8P2pbHpvrrTa6L5oRAqWrAJ0RPOMtsW4IhBTkzKycyJnnZHwATACfTct6
Pi2wOViPXfXlpR1V3iw78Is=
=RpGT
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
On Friday, January 11, 2002, at 05:42  PM, Nick Wilson wrote:

> That's not it. Your first $result is a resource indicator (container for
> results) so if you re-assign it (put another value into it) it becomes
> useless as your while statement depends on it.


(This may be redundant, but I'm hoping that someday someone will find 
this info in the archives as helpful:)

<INSIGHT!>

Now I understand.  I was mistaken in the way that I first conceptualized 
the following:

$sql = "some SQL code";
$result = mysql_query($sql, $db);

Originally, I thought that $result was just a variable that represented 
the function "mysql_query($sql, $db)".  And when $result is called by, 
for instance, mysql_fetch_array(), in the form 
"mysql_fetch_array($result)", all I was really doing was making a more 
organized form of this:

       mysql_fetch_array((mysql_query($sql, $db)))

But no!  It appears that defining the variable $result like so:

$result = mysql_query($sql, $db);

Is actually performing an operation!  The mysql_query() function happens 
at this time!  Not during the mysql_fetch_array() as I previously 
thought.

If what I have written above here is correct (and I hope it is) then you 
have helped me learn a fundamental element of the way PHP works, at 
least with this command.  I had not been thinking of $result as a 
"container for results" before, rather as a "container for another 
function for later use".

Awesome.

Erik


--- End Message ---
--- Begin Message ---
After lots of trial and error I traced the problem back to a missing
browscap.ini, I commented out that line in php.ini and it worked
fine. I guess it was causing php to think the it wasn't dealing with
a browser so it sent the headers differently (or something)

thanks to everyone.

- Mark

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

I am currently developing a site which makes use of SSL and sessions.
However, sometimes when I submit
form data (from an SSL page to another SSL page on the same server), I get
an error saying "This page
contains both secure and unsecure items. Do you want to display the
nonsecure items" (I have had these
results in IE5.5 and IE6, possibly IE5 too). If I press yes, a DNS error
page appears. If i press no,
a page saying simply "NavigationCancelled" (without any spaces) appears.
This error seems to happen
randomly, and only when form data is being sent with POST (I haven't tried
it with GET or anything else
as it may be a security risk to have the form contents displayed in the
query string).

I have found a way to fix this, however, it had some undesirable affects
with pages being cashed (and
therefore not being displayed with any changed session variables). This
"fix" was done using session_cache_limiter('private'),
but I don't want to use this due to these caching effects.

Does anyone have any suggestions that could fix this problem? I would be
very grateful.

Richard Hilton.



--- End Message ---
--- Begin Message ---
I am looking for a php script that allows me to upload a file via a browser,
and the generates an automatic link on a predefined page.

Is that possible?

Regards
[EMAIL PROTECTED]



--- End Message ---
--- Begin Message ---
This is probably more of an HTML question, but...

I would like to have the ability to upload files onto a site, however using
the normal HTML <input type=file...> results in a somewhat disgusting
looking control which I cannot seem to get to fit into my site's theme.

Is there a better way - remembering of course that I still need the facility
to browse the local system for a file


Thanks
--
Alan McFarlane
[EMAIL PROTECTED]
ICQ: 20787656


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

I´m trying to develop a search engine where users could search not only individual 
words, but also phrases enclosed by "", but I´m having trouble to build the function 
to recognize each phrase and individual word from a variable sent with html form.

Did anybody make something like this? Can you help me in this point?

Thank you in advance.

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

It all started when I wanted to create a photography competition and forum
on my web site.  I searched and searched for a program (script) on the web
that would help me.

I found one and paid $125.00 for it, but I am very unhappy with the way it
works.  It is not very user friendly and I'm loosing potential members
because of it.  I have asked the programmer to assist me in creating it the
way I want it, he said he would,
I have yet to see the updates I requested.  So I've taken it upon myself to
create a script tailored to my needs.

I have written HTML, some JavaScript, and very little CGI.  I thought I
could handle creating this script.  I went to my nearest Barnes and Noble
and bought 5 books on PHP and MySQL.  I have been reading them for 2 weeks
and doing the lessons in one of the books until I'm bleary eyed.  I have a
basic understanding, but I don't know where to begin.

I'm looking for someone with a little patience, who can get me on the right
path and guide me through.  I don't know what I can give you in return...we
can talk about it if you're interested.

P. Westover


--- End Message ---
--- Begin Message ---
Cold Fusion, as far as I'm concerned, stinks.  However, I have been involved
in porting a website from Cold Fusion to PHP and during this
transmogrification, I've come across something I'm not sure how to emulate
in PHP.  Perhaps if there are any CF/PHP gurus out there, they can help me
out.

The tag I am talking about is <CFHTTP>.  This tag allows you to emulate the
posting of a form, but also allows you to capture the results of the post.
There are a couple of forms written in CF that connect to the merchant
account, check a credit card, for example, and then wait for the
approval/denial response.

Is there anything in PHP that can do this same kind of thing?  Any help
would be appreciated.

Best regards,

Jeremy Reed


--- End Message ---
--- Begin Message ---
Google for something called PostToHost I wrote ages ago.  Lots of
variations of that around.  Basically you just fsockopen() to the site in
question and fputs() your request and POST data and then fgets() the
result.

-Rasmus

On Fri, 11 Jan 2002, Jeremy Reed wrote:

> Cold Fusion, as far as I'm concerned, stinks.  However, I have been involved
> in porting a website from Cold Fusion to PHP and during this
> transmogrification, I've come across something I'm not sure how to emulate
> in PHP.  Perhaps if there are any CF/PHP gurus out there, they can help me
> out.
>
> The tag I am talking about is <CFHTTP>.  This tag allows you to emulate the
> posting of a form, but also allows you to capture the results of the post.
> There are a couple of forms written in CF that connect to the merchant
> account, check a credit card, for example, and then wait for the
> approval/denial response.
>
> Is there anything in PHP that can do this same kind of thing?  Any help
> would be appreciated.
>
> Best regards,
>
> Jeremy Reed
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

--- End Message ---
--- Begin Message ---
I have need to be able to replace text within a string to turn it into a
link.  In other words, I might have a phrase lik:

"blah, blah, blah, please visit my site at www.mysite.com.  blah,
blah,blah".

I need to have the string converted to "blah, blah, blah, please visit my
site at http://www.mysite.com.  blah, blah,blah".  The link might have more
than 3 sections and won't necessarily end in .com (.net,.com.nl, etc.).

Here is what I have been testing (then I get stuck):
$myLink = "Please visit my web site at www.mysite.com. You will be glad you
did!";
$repLink = preg_replace("/(www.)/i","<a href=http://\\1",$myLink);

which yields
Please visit my web site at <a href=http://www.mysite.com. You will be glad
you did!

What I would need is
Please visit my web site at <a
href=http://www.mysite.com>www.mysite.com</a>. You will be glad you did!

To be truthful, pattern matching is giving me migraines!  Programming has
always been natural to me (32 years of it), but this challenge (eregi,
preg_match,etc.) is making me crazy!  Can someone recommend a good tutorial
or book on this subject?

Thanks!



--- End Message ---
--- Begin Message ---
on 1/11/02 8:20 PM, Gaylen Fraley at [EMAIL PROTECTED] wrote:

> Can someone recommend a good tutorial
> or book on this subject?

Mastering Regular Expressions
Jeffrey Friedl
O'Reilly & Associates
ISBN 1-56592-257-3

 -- mike cullerton 


--- End Message ---
--- Begin Message ---
Hi,
If I have en ENUM column in a mysql table, can I leverage
this through PHP to restrict user entry with a list?
Other option that I have is to create a lookup table, or
use an array.

=====
Mehmet Erisen
http://www.erisen.com

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--- End Message ---
--- Begin Message ---
On Saturday 12 January 2002 11:30, Mehmet Kamil ERISEN wrote:
> Hi,
> If I have en ENUM column in a mysql table, can I leverage
> this through PHP to restrict user entry with a list?
> Other option that I have is to create a lookup table, or
> use an array.

You'll need to adapt this for your own use, but hopefully you'll get the 
general idea.

#===========================================================
# create_list_from_ENUM
#-----------------------------------------------------------
# Returns array [enum vals]
#
# Arguments
# ---------
#
# $dbh    : a $dbh object defined in class.DBI.inc
# $table  : the table to get the ENUM values from
# $column : the column containing the ENUM values
#
#===========================================================
function create_list_from_ENUM($dbh, $table, $column) {
  $sth = $dbh->prepare("SHOW COLUMNS FROM $table LIKE '$column'");
  if ($sth) {
    $sth->execute();
    while ($row = $sth->fetchrow_hash()) {
      ereg("('(.*)')", $row[1], $temp);
      $array = explode( "','", $temp[2] );
      while (list ($key, $val) = each ($array)) {
        $return[] = "$val";
      }
    }
  }
  return $return;
}


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
A shortcut is the longest distance between two points.
*/
--- End Message ---
--- Begin Message ---
how to set cookies in win98 using PWS ?
if i set the session of php.ini, where is the cookies setting ?

Mpu Strees

--- End Message ---

Reply via email to