php-general Digest 20 Jan 2001 17:24:25 -0000 Issue 466

Topics (messages 35781 through 35814):

Re: Classes question.
        35781 by: Matt McClanahan

IMAP_HEADER
        35782 by: Jochen Kächelin

IMAP_HEADER NEW!!
        35783 by: Jochen Kächelin

Re: Date/Time Formatting
        35784 by: Jeff Lacy

Form refresh problem
        35785 by: Lucas Young
        35795 by: Richard Lynch

Re: Help - removal of trailing zeros from double integer field
        35786 by: ravi.nls.ac.in

Re: Question about session_register()
        35787 by: Richard Lynch

Re: Session problem?
        35788 by: Richard Lynch

Re: problems creating a png image from an array{HELP} including the source code
        35789 by: Richard Lynch

Re: Using a variable in a variable or as the second part of an array?
        35790 by: Richard Lynch

Re: Image problem
        35791 by: Richard Lynch

Re: PHP Parse MySQL Field???
        35792 by: Richard Lynch

Re: Help, can't seem to get this write
        35793 by: Richard Lynch

Re: ibase_num_fields() -a workaround ?
        35794 by: Richard Lynch

Flushing vars
        35796 by: jalist

Re: Profanity Filter
        35797 by: Nik Gare
        35809 by: Website4S.aol.com

Re: Spell checker?
        35798 by: Nik Gare
        35811 by: Kristi Russell

Re: PHP Parse MySQ: Field???
        35799 by: [ rswfire ]

getting from PHP the vars that are in the memory during the execution of the script...
        35800 by: Romulo Roberto Pereira

Re: Running java under php4 (PHP4 ext/java)
        35801 by: Fraser MacKenzie

Pre-loading HTML form w/ mySQL data
        35802 by: Anthony Rodriguez
        35803 by: Kath
        35806 by: Romulo Roberto Pereira

Image Widths/Heights on Upload
        35804 by: Bryan Fritchie

MySQL problem
        35805 by: Alaiddin Tayeh

Help w/ regular expressions for banned words
        35807 by: Team JUMP
        35813 by: CC Zona

Macromedia UltraDev 4 MySQL connection
        35808 by: Murph

Please: XTemplate help?
        35810 by: Jaxon
        35814 by: Kristi Russell

HELP!. INstalling PHP4 on a Cobalt RAQ 2!
        35812 by: Trunkz Santai

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]


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


On Fri, 19 Jan 2001, James McLaughlin wrote:

> I get an error when doing this....
> 
> class Something
> {
>     var $something;
> 
>     function Something($this->something)
>     {
>         More somethings
>     }
> 
> }
> 
> The error tells me that I need a ")" in the line the function call is
> in.  If I take the "$this->something" it will parse fine.  Can you not
> do this?

No, you can't do this.  Functions within the class can automatically get
to class variables with $this->something, so passing them as parameters
would be somewhat redundant.

class Something
{
   var $something;

   function Something()
   {
      $this->something = "More somethings";
   }
}

Matt





Need some help!

I will extract the email from the sender of an email:

        $header = imap_header($link,1,0,1024);
        $sender = $header->fromadress;

But i will only get the Realname of the sender!
How do I get his eMail?


--
**********************************************
* Jochen Kächelin                            *
* Ihr WEBberater - Werbeagentur Pulvermüller *
* Stuttgarter Str. 3 - D-73033 Göppingen     *
* www.wa-p.de - mailto:[EMAIL PROTECTED]          *
**********************************************





Need some help!

I will extract the email-address from the sender of an email:

        $header = imap_header($link,1,0,1024);
        $sender = $header->fromadress;

In the manual I read about from[] , personal, adl, mailbox, host!

How can I grab the contents of these fields?

But i will only get the Realname of the sender!
How do I get his eMail?


--
**********************************************
* Jochen Kächelin                            *
* Ihr WEBberater - Werbeagentur Pulvermüller *
* Stuttgarter Str. 3 - D-73033 Göppingen     *
* www.wa-p.de - mailto:[EMAIL PROTECTED]          *
**********************************************





When you are doing you select try something more along the lines of:

select date_format(date, '%e,%c,%Y') from tblmycoolstuff;

I got most of this stuff from
http://www.mysql.com/doc/D/a/Date_and_time_functions.html You need to look
at the table on that page to get the date to print out exactly as you want
it.  I know date_format works with the timestamp column type, but I don't
know (but I assume) that it works the same exact way for some of the other
types that store dates :-)

If you still are having trouble, maybe I could help you?

Jeff


""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message
01e801c08244$85dfd640$[EMAIL PROTECTED]">news:01e801c08244$85dfd640$[EMAIL PROTECTED]...
> > Also I'd like to if possible to be able to enter and display the date in
> > Australian / European Time format (DD,MM,YYYY)
> > I'm currently entering it on the form using three text fields and then
> > rearanging them to the Format in mySQL and indserting it as a string,
but
> I
> > don't know how to 'break' up a mySQL Date value to rearange it.
>
> The breaking up of a MySQL date would be in the MySQL manual at
> http://mysql.org
> I dunno what it's called...  In PostgreSQL it's "date_part" though :-)
>
> I'm afraid there was another question in there somewhere, but I couldn't
> really discern it -- What you are doing seems quite reasonable to me.
>
>
>
> --
> 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]
>






Hi Guys

I'm having a bit of a problem with form submission. I'm creating an opinion
poll, and the user's vote is submitted as a form back to the originating
page. I'm using !isset to see if the form has been submitted and if so,
updating the database and showing the current results
My problem is that a user, having voted once, can keel clicking refresh in
their browser and the form data keeps getting sent, incrementing the poll
results each time
Is there a way to kill form data once it;s been posted, or is there a better
way of doing what I am trying to accomplish?

Many thanks

Lucas Young






> My problem is that a user, having voted once, can keel clicking refresh in
> their browser and the form data keeps getting sent, incrementing the poll
> results each time
> Is there a way to kill form data once it;s been posted, or is there a
better
> way of doing what I am trying to accomplish?

The easiest way to stop most multiple votes is to send them a Cookie when
you get their vote.

If they have that Cookie, they can't vote again.

That won't stop a semi-serious cheater -- He'll just not accept the Cookie
or delete it after he gets it or...

If you need better than this minimal "honesty" factor, it gets tricky...
And *NOTHING* online (via HTTP, anyway) can be anywhere close to a reliable
voting method.  Even Florida had it better. :-)

By Day:                                |By Night:
    Don't miss the Zend Web Store's    |   There's not enough room here...
    Grand Opening on January 23, 2001! |   Start here:
    http://www.zend.com                |   http://l-i-e.com/artists.htm






Dear friends,

I am accessing MySQL database using apache and php.
I have to display a double integer field without trailing zeros.
The number of digits after the decimal point varies.

I have tried searching the archive and did not get any previous questions.

Kindly help me in this regard.

Thanking you.
Sincerely,
Raveendra Reddy B
National Law School
Bangalore
India
E-mail: [EMAIL PROTECTED]

----- End forwarded message -----




> My question is, when the user first visit, a session created, and I
register
> the variable. On the second, or following hits, to use the session
variable,
> I also need "session_start", but should I still need to call
> session_register() for each hit?

No, once you register it, it's there unless you 'unregister' it.


By Day:                                |By Night:
    Don't miss the Zend Web Store's    |   There's not enough room here...
    Grand Opening on January 23, 2001! |   Start here:
    http://www.zend.com                |   http://l-i-e.com/artists.htm






> function add_toCart($id,$array) {
> session_register("OBJECT");
> $c = new Configurator;
> $c->readConfig($id);
> $OBJECT = serialize($c);
> header("Location: Cart.php");
> echo "Redirecting..."
> }
>
> Unfortunately, the session file (in /tmp) is always empty after this
> function executes.  I'm using PHP 4.0.4 with --enable-trans-sid.

I don't think you can do a Location and a Cookie in the same page, and the
Sessions are done with Cookies, so...

Don't do that.

Sorry.

By Day:                                |By Night:
    Don't miss the Zend Web Store's    |   There's not enough room here...
    Grand Opening on January 23, 2001! |   Start here:
    http://www.zend.com                |   http://l-i-e.com/artists.htm






> <?
> $size_x=1000;
> $size_y=1000;
> $ECODE=12;
>
> file://$filename='list.txt';
> echo "<p style=\"font-family : 'Courier New';font-size : 'x-small'\">";
> $id=1;
> $i=1;
> echo "<h1>?? ?????? $filename ?? ????? ETNA</h1>";
> if ($fp=fopen($filename, "r"))
> {
>   while (!feof($fp))
>   {
>     $trimmed_line=trim($line=fgets($fp, 80));
>     if (strstr($trimmed_line, "Handle"))
>     {
>       $handle=substr($trimmed_line, 9, 4);
>       $trimmed_line=trim($line=fgets($fp, 80));
>       if (!strstr($trimmed_line, "from point"))
>         $trimmed_line=trim($line=fgets($fp, 80));
>       $from_x=trim(substr($trimmed_line, 14, 9));
>       $from_y=trim(substr($trimmed_line, 27, 9));
>       $trimmed_line=trim($line=fgets($fp, 80));
>       if (!strstr($trimmed_line, "to point"))
>         $trimmed_line=trim($line=fgets($fp, 80));
>       $to_x=trim(substr($trimmed_line, 12, 9));
>       $to_y=trim(substr($trimmed_line, 25, 9));
>       $pipes[$i][0]=($from_x);
>       $pipes[$i++][1]=($from_y);
>       $pipes[$i][0]=($to_x);
>       $pipes[$i++][1]=($to_y);

So, like, are you sure that ++ really happens after the array assignment is
done?...
I'm probably just a Luddite, but I don't trust ++ and assignment operations
*that* far.

>       $id++;
>     }
>   }
> }
>
> $nodes=array_values(array_unique($pipes));
> for ($i=0;$i<sizeof($nodes);$i++)
> {
>   $k=$i+1;
>   echo "$k,";
>   echo $nodes[$i][0];
>   echo ",";
>   echo $nodes[$i][1];
>   echo "/<br>";
> }
> echo "-1//<br>";
> $temp_pipes=$pipes;
>
> $i=sizeof($temp_pipes);
> $size=$i;
> $pipe_id=1;
> while(!empty($temp_pipes))
> {
>   $current_node=array_shift($temp_pipes);
>   reset($nodes);
>   while((current($nodes))!=$current_node)
>   {next($nodes);}

This looks suspicous...  I'm not quite sure what's going on here, but I'm
expecting you'd want to walk from node to node, or maybe skip any
duplicates, but why are you zipping through the entire array looking for the
node that you are on?...
There's got to be a better way to track this -- maybe just using an indexed
array for your nodes, and knowing that you are currently on $node_index or
something...
Is a "node" an array?  I wouldn't be using == on two arrays...  Maybe it's
fine, but again that Luddite factor works in, and I'd be testing the
elements individually...

>   $pipes_nodes[$size-$i+1][0]=key($nodes)+1;
>   echo ($pipe_id++).",$ECODE,".$pipes_nodes[$size-$i+1][0];
>
>   $current_node=array_shift($temp_pipes);
>   reset($nodes);
>   while((current($nodes))!=$current_node)
>   {next($nodes);}

Same here...

>   $pipes_nodes[$size-$i+1][1]=key($nodes)+1;
>
>   echo ",".$pipes_nodes[$size-$i+1][1]."/<br>";
> }
> echo "-1//<br>";
> if (!isset($pressure_drop_nodes))
>

>     echo "<form action='convert.php' method='post' name='form_convert'
id='1'>";
>     echo "<TABLE border=0 width='80%'>";
>     echo
> "
>   <TR>";
>     echo "      <TD width='30%'>?????? ????? ??????? ??????? ?????
> ??????:</TD>";
>     echo "      <TD width='50%'><INPUT size=50 value=''
> name=pressure_drop_nodes></TD>";
>     echo "  </TR>";
>     echo "  <TR>";
>     echo "      <TD width='30%'>&nbsp;</TD>";
>     echo "      <TD width='50%'>(?? ?????? ?? ?????????? ?? ?????, ?.?.
> '1,2,12,5')</TD>";
>     echo "  </TR>";
>     echo "  <TR>";
>     echo "      <TD width='30%'>?????????????? ??? ??????:</TD>";
>     echo "      <TD width='50%'>1,".sizeof($nodes).",1,'ELD','DI',<INPUT
> size=4 value='' name=diameter>,'RK',<INPUT size=6 value=''
> name=traxitita></TD>";
>     echo "  </TR>";
>     echo "  <TR>";
>     echo "      <TD width='30%'>&nbsp;</TD>";
>     echo "      <TD width='50%'>&nbsp;</TD>";
>     echo "  </TR>";
>     echo "  <TR>";
>     echo "      <TD width='30%'></TD>";
>     echo "      <TD width='50%'></TD>";
>     echo "  </TR>";
>     echo "</table>";
>     echo "  <INPUT type='Hidden' value='$filename' name='filename'>";
> }
>
// -------------------------------------------------------------------------
> ----
> file://phpinfo();
> if (isset($pressure_drop_nodes))
> {
>     echo "1/<br>";
>     $individual_nodes=explode(",", $pressure_drop_nodes);
>     for($i=0;$i<sizeof($individual_nodes);$i++)
>     {
>         echo "$individual_nodes[$i]/<br>";
>     }
>     echo "-1//<br>";
>     echo
>
"1,".sizeof($nodes).",1,'ELD','DI',".$diameter.",'RK',".$traxitita."/<br>";
> }
> echo "-1//<br>";
> echo "-1/<br>";
> echo "-1/<br>";
> echo "-1/<br>";
> echo "-1/<br>";
> echo "1,0/<br>";
>
> if (!isset($pressure_drop_nodes))
>

>     echo "<TABLE border=0 width='80%'>";
>     echo "  <TR>";
>     echo "      <TD width='30%'>?????? ??????:</TD>";
>     echo "      <TD align=right width='50%'></TD>";
>     echo "  </TR>";
>     $y=0;
>     for($i=0;$i<sizeof($nodes);$i++)
>     {
>         $y=$i+1;
>         echo "  <TR>\n";
>         echo "      <TD width='30%'>$y</TD>\n";
>         echo "      <TD width='50%' align=right >\n";
>         echo "          $y,<INPUT siz
> e=4 value='' nam
> e=to_node".$y.">,1,'\n";
>         echo "          <select name=type".$y.">\n";
>         echo "              <option value='PRE' selected>PRE</option>\n";
>         echo "              <option value='DIS'>DIS</option>\n";
>         echo "          </select>',\n";
>         echo "          '<select name=units".$y.">\n";
>         echo "              <option value='BAR' selected>BAR</option>\n";
>         echo "              <option value='M3H'>M3/H</option>\n";
>         echo "          </select>',\n";
>         echo "          <INPUT size=4 value='' name=pre_dis".$y.">\n";
>         echo "      </TD>\n";
>         echo "  </TR>\n";
>     }
>     echo "  <TR>";
>     echo "      <TD width='30%'></TD>";
>     echo "      <TD width='50%'><input type='submit' value='Continue'
> name='submit'>&nbsp;<input type='Reset'></TD>";
>     echo "  </TR>";
>     echo "  <INPUT type='Hidden' value='$y' name='no_of_loads'>";
>     echo "</table>";
>     echo "</form>";
> }
> else if (isset($pressure_drop_nodes))
> {
>
>   for ($i=1;$i<=$no_of_loads;$i++)
>   {
>     $to_node='to_node'.$i;
>     $type='type'.$i;
>     $units='units'.$i;
>     $value='pre_dis'.$i;
>     $to_node =$HTTP_POST_VARS[$to_node];
>     $type    =$HTTP_POST_VARS[$type];
>     $units   =$HTTP_POST_VARS[$units];
>     $value   =$HTTP_POST_VARS[$value];
>
>     if ($type=='PRE')
>     {
>         if($to_node!='')
>         {
>             echo "$i, $to_node, $type, $units, $value<br>\n";
>             $temp=$to_node;
>         }
>         else if ($to_node!=='')
>         {
>             if ($i<=$temp)
>             {
>               echo "$i, $i, $type, $units, $value<br>\n";
>             }
>         }
>     }
>   }
>
>   for ($i=1;$i<=$no_of_loads;$i++)
>   {
>     $to_node='to_node'.$i;
>     $type='type'.$i;
>     $units='units'.$i;
>     $value='pre_dis'.$i;
>     $to_node =$HTTP_POST_VARS[$to_node];
>     $type    =$HTTP_POST_VARS[$type];
>     $units   =$HTTP_POST_VARS[$units];
>     $value   =$HTTP_POST_VARS[$value];
>
>     if ($type=='DIS')
>     {
>         if($to_node!='')
>         {
>             echo "$i, $to_node, $type, $units, $value<br>\n";
>             $temp=$to_node;
>         }
>         else if ($to_node!=='')
>         {
>             if ($i<=$temp)
>             {
>               echo "$i, $i, $type, $units, $value<br>\n";
>             }
>         }
>      }
>   }
>
> }
>
>
> echo "-1/<br>";
> echo "-1/<br>";
> echo "-1/<br>";
>
> for ($i=1;$i<=sizeof($nodes);$i++)
> {
>   $temp1[2*($i-1)]=$nodes[$i][0];
>   $temp2[2*($i-1)]=$nodes[$i][1];
> }
> $merged=array_merge($temp1, $temp2);
> $max=max($merged);
> $min=min($merged);
> $points=$pipes;
> for ($i=1;$i<=sizeof($points);$i++)
> {
>   $points[$i][0]=floor( ($points[$i][0]*($size_x-10)/$max) );
>   $points[$i][1]=floor( ($points[$i][1]*($size_y-10)/$max) );
> }
>
> $point_ids=$nodes;
> for ($i=0;$i<sizeof($point_ids);$i++)
> {
>   $point_ids[$i][0]=floor( ($point_ids[$i][0]*($size_x-10)/$max) );
>   $point_ids[$i][1]=floor( ($point_ids[$i][1]*($size_y-10)/$max) );
> }
>
>
> @fclose($fp);
>
> for ($i=1;$i<=sizeof($points);$i++)
> {
>   $string=$string."&x".$i."=".$points[$i][0]."&y".$i."=".$points[$i][1];
> }
> for ($i=0;$i<sizeof($point_ids);$i++)
> {
>
>
$string=$string."&id_x".$i."=".$point_ids[$i][0]."&id_y".$i."=".$point_ids[$
> i][1];
> }
> $string=substr($string,
> 1)."&size=".sizeof($points)."&size_ids=".sizeof($point_ids);
> $string="display.php?".$string."&size_x=".$size_x."&size_y=".$size_y;
>
> echo "<MAP name=\"map\">";
> for ($i=0;$i<sizeof($point_ids);$i++)
> {
>   echo "<AREA coords='".($point_ids[$i][0]+2).",";
>   echo ($point_ids[$i][1]+2).",".
> ($point_ids[$i][0]-2).",".($point_ids[$i][1]-2);
> //  echo "' alt=\"".($i+1)."\" href=\"".$i."\">";
> echo "' alt=\"".($i+1)."\"
>
href=\"".$string."&zoom_x=".($point_ids[$i][0])."&zoom_y=".($point_ids[$i][1
> ])."\">";
>
> }
> echo "</MAP>";
>
> echo "<img src='$string' usemap='#map' style='border-color:black'>";
> file://echo "<a href='$string' usemap='#map'>link</a>";
>
> display.php
> <?
> $factor=3.5;
>
> for ($i=1;$i<=$size;$i++)
> {
>   $x='x'.$i;
>   $y='y'.$i;
>   $points[$i][0]=$HTTP_GET_VARS[$x];
>   $points[$i][1]=$HTTP_GET_VARS[$y];
> }
>
> for ($i=0;$i<$size_ids;$i++)
> {
>   $x='id_x'.$i;
>   $y='id_y'.$i;
>   $point_ids[$i][0]=$HTTP_GET_VARS[$x];
>   $point_ids[$i][1]=$HTTP_GET_VARS[$y];
> }
>
> if (isset($zoom_x) && isset($zoom_y))
> {
>   for($i=0;$i<sizeof($point_ids);$i++)
>   {
>  $x=($point_ids[$i][0]-($zoom_x-$size_x/2))*$factor-(($size_x/4)*$factor);
>  $y=($point_ids[$i][1]-($zoom_y-$size_y/2))*$factor-(($size_y/4)*$factor);
>     if ((($x>0)&&($x<$size_x))&&(($y>0)&&($y<$size_y)))
>  {
>    $n_point_ids[$i][0]=$x;
>    $n_point_ids[$i][1]=$y;
>  }
>  else
>  {
>    $n_point_ids[$i][0]=-1;
>    $n_point_ids[$i][1]=-1;
>  }
>   }
>   for($i=1;$i<=sizeof($points);$i++)
>   {
>  $x=($points[$i][0]-($zoom_x-$size_x/2))*$factor-(($size_x/4)*$factor);
>  $y=($points[$i][1]-($zoom_y-$size_y/2))*$factor-(($size_y/4)*$factor);
>     if ((($x>0)&&($x<$size_x))&&(($y>0)&&($y<$size_y)))
>  {
>    $points[$i][0]=$x;
>    $points[$i][1]=$y;
>  }
>  else
>  {
>    $points[$i][0]=-1;
>    $points[$i][1]=-1;
>  }
>   }
> }
>
> file://Header("Content-type: image/gif");
>
> $im=@imagecreate($size_x, $size_y);
> $background_color = ImageColorAllocate ($im, 255, 255, 255);
> $orange = ImageColorAllocate($im, 220, 210, 60);
> $black  = ImageColorAllocate($im, 0, 0, 0);
> $red    = ImageColorAllocate($im, 255, 0, 0);
> $green  = ImageColorAllocate($im, 0, 255, 0);
>
> if (!isset($zoom_x))
> {
>   for ($i=1;$i<=sizeof($points);$i=$i+2)
>   {
>    imageline($im, $points[$i][0], $points[$i][1], $points[$i+1][0],
> $points[$i+1][1], $orange);
>     ImageString($im, 7, ($points[$i][0]+$points[$i+1][0])/2-5,
> ($points[$i][1]+$points[$i+1][1])/2, ($i+1)/2,   $red);
>   }
>   for ($i=0;$i<sizeof($point_ids);$i++)
>
>
>     $str=strval($i+1);
>     ImageString($im, 7, $point_ids[$i][0]+1,   $point_ids[$i][1]+1,
$str,
> $black);
>     ImageRectangle($im,$point_ids[$i][0]+2,  $point_ids[$i][1]+2,
> $point_ids[$i][0]-2,  $point_ids[$i][1]-2,  $black);
>     imagefilltoborder ($im,$point_ids[$i][0],$point_ids[$i][1], $black,
> $black);
>   }
> }
> if (isset($zoom_x))
> {
>   for ($i=1;$i<=sizeof($points);$i=$i+2)
>   {
>     if(($points[$i][0]>0)&&($points[$i+1][0]>0))
>  {
>       imageline($im, $points[$i][0], $points[$i][1], $points[$i+1][0],
> $points[$i+1][1], $orange);
>       ImageString($im, 7, ($points[$i][0]+$points[$i+1][0])/2-5,
> ($points[$i][1]+$points[$i+1][1])/2, ($i+1)/2,   $red);
>     }
>   }
>   for ($i=0;$i<sizeof($n_point_ids);$i++)
>
>
>     if($n_point_ids[$i][0]>0)
>  {
>       $str=strval($i+1);
>       ImageString($im, 7, $n_point_ids[$i][0]+1,   $n_point_ids[$i][1]+1,
> $str,   $black);
>       ImageRectangle($im,$n_point_ids[$i][0]+5,  $n_point_ids[$i][1]+5,
> $n_point_ids[$i][0]-5,  $n_point_ids[$i][1]-5,  $black);
>       file://imagefilltoborder
($im,$n_point_ids[$i][0],$n_point_ids[$i][1],
> $black, $black);
>  }
>   }
> }
> Imagepng($im);
> Imagepng($im, "map.png");
> ?>
> ?>
> > > I create from the array the image from the network.When the txt file
is
> > > >21Kb there is no image, else all works perfect{with a smaller txt
> file).I
> > > am using php4,apache(sometimes my system hangs with this server) or
OMNI
> > > httpd(works fine).
> > > If anybody know sth PLEASE HELP ME
> > > I am newbie in php programming
>
>
>
>
> --
> 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]
>
>
>
>
> --
> 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]
>





> I need to simulate this effect:  $array[$i] or \$something . $i, and have
it
> return $checkbox1 $checkbox2 etc. on up in a while loop.
> Just doing it doesn't seem to work, but does anyone know of any work
> arounds?  Or just the keyword I should be looking for to search the
manual?

You could be using "variable variables" to do that, but for checkboxes, it's
way more better to use arrays:

<INPUT TYPE=CHECKBOX NAME=checkbox[1] VALUE=42>
<INPUT TYPE=CHECKBOX NAME=checkbox[2] VALUE='Life, the Universe, and
Everything'>

Now your processing page can just iterate through $checkbox:

while (list($key, $value) = each($checkbox)){
    echo "$key -- $value was checked<BR>\n";
}

Only thing to watch out for -- If nothing is checked, $checkbox won't be an
array, and each() will give an error message.

So add this above that:
if (!isset($checkbox)){
    $checkbox = array();
}

This checkbox/array stuff is in the FAQ, so read that http://php.net/FAQ.php
and the "variable variables" is in the online manual also.

> I have a form being generated from a database.  For every entry in the
> database, there'll be a checkbox in the form.  Basically, I need a way of
> accessing the values of that checkbox (any or all of the checkboxes can be
> checked, too). The names of the checkbox would increment up like checkbox1
> checkbox2 etc.  Since I have no clue how many people are in the database,
> that increment needs to be some sort of variable, so I can read the value
> from that checkbox (whether or not it's checked) when the form is
submitted.
> Did that make any sense?  Sorry I was so vague.
>
>
> --
> 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]
>





> Can anyone tell me how to display both jpg and gif images.  Basically,
> what i've got is:
> <img src="$filedir/$CUserName".jpg>
>
> Now, I know I probably need slashes in there and I played around with it
> but no luck. Where do I put them?

TIP:  Use "View Source" in your browser to see what the IMG tag looks like.

I suspect you've forgotten that you're not in PHP mode, and are just sending
a very oddly-named image tag, literally:
"$filedir/$CUserName"

Since the quotes are going there, I guess HTML is going to ignore the .jpg
part, or treat it as an unkown attribute.

I'm guessing you want:

<img src="<?php echo $filedir, '/', $CUserName, '.jpg';?>">






>I have a BLOB field in a MySQL database that I want
>to parse into my page using PHP.
>For instance, in this field might be the following:
>
><?  echo "test";  ?>
>
>So when I access this field in PHP I want it to display "test".
>
>Is this possible?

Yeah.  That's called "eval" (short for 'evaluate')

Basically you can make PHP execute arbitrary chunks of more PHP code.

NOTE:  Letting web-surfers insert PHP code into your database to be
evaluated later is really high on the Bad Idea list...  Actually, doing this
on a web-site where you're not pretty sure the database itself is pretty
secure from not only surfers but also other potentially malicious co-users
on the same box...  It's just too easy for them to be able to put mean code
in your database...

http://php.net/eval

I *think* it goes like this:

<?php
    $php = 'echo "Hi";';
    eval($php);
?>

Never used it myself...

By Day:                                |By Night:
    Don't miss the Zend Web Store's    |   There's not enough room here...
    Grand Opening on January 23, 2001! |   Start here:
    http://www.zend.com                |   http://l-i-e.com/artists.htm






> function downloadfile($url, $imageDir)
>  {
>   if(!$file = fopen($url , "r"))
>    {
>     echo ("couldn't open $url\n");
>    }
>   else
>    {
>     #fpassthru($file);
>     if($file2 = fopen("/www/sinead/images/Full/Sinead200.jpg", "w"))
>      {
>       $content=fread($file, filesize("$file"));
>       fwrite($file2, $content, filesize("$file"));

Having quotes on the $file arguments to filesize() is not right...
Hey, doesn't filesize() take the *path* to a file, not a file pointer?
Yeah, it does:  http://php.net/filesize
So, like, you're asking for the filesize of a file named '1' or whatever the
file pointer id number is.
Actually, I don't think you can get a filesize() of a URL anyway...

You're going to just have to get like a million bytes or whatever you think
convenient, and loop until you got it all.

>       echo ("$file2 created");
>      }
>    }
>  }
> ?>


By Day:                                |By Night:
    Don't miss the Zend Web Store's    |   There's not enough room here...
    Grand Opening on January 23, 2001! |   Start here:
    http://www.zend.com                |   http://l-i-e.com/artists.htm






> ibase_num_fields() isn't functional in php 4 - anyone have any ideas to
> work around this ?
>
> I'm checking the number of results for a query to check if a
> user/password is correct -I suppose I could just do a fetch_row() on the
> result and test if thats empty or not - but I'll only do that  as a last
> resort

select count(*) from users where userid = '$userid' and password =
password('$password')

might be a good choice.

Actually, I usually like to check userid first, and then password -- I
prefer to inform the user if their username is wrong or just the password.
Lord knows I've got enough usernames/passwords on all these darn sites that
I sure appreciate it when somebody tells *me* I ain't even remembering the
username right, much less the password.

By Day:                                |By Night:
    Don't miss the Zend Web Store's    |   There's not enough room here...
    Grand Opening on January 23, 2001! |   Start here:
    http://www.zend.com                |   http://l-i-e.com/artists.htm






I know this must have been asked before so I apologize in advance...

Is there a way to flush the $PHP_AUTH_USER / $PHP_AUTH_PW vars? I have a
routine where someone can logon to my admin section as a guest and enter a
new username/password. Is it possible for him to then logout (flushing the
guest vars) and re-login under his new u/p?

Thanks in advance

Steve





In article <94adfp$5le$[EMAIL PROTECTED]>,
   Stephan Ahonen <[EMAIL PROTECTED]> wrote:
> I'd make it an array:

> $filter = array(moron, idiot, pratt);

> foreach($filter as $badword) {
>  if (strstr($name, $badword)) {
>   do this if it contains one of the bad words
>  }
>  else {
>   do this if it doesn't
>  }
> }

But wouldn't this approach have its drawbacks, too?
For example, I live in Kiel, Germany, about 20km from a town called
Wankendorf.  Presumably I wouldnÄt be able to say this.

Nik





Hi,

I`m trying to use the code below for my profanity checker but it keeps 
returning a parse error on the second line 'while ((list etc'

Can anyone see anything wrong??

TIA
Ade

<< $done=false;
 while ((list($key, $val)=each($words)) and $done===false)
 {
   $done=strpos(strtolower($name), $val);
 };
 if ($done!==false)
 {
   // Oops! Bad name.
 }
 else
 {
   // Okay, valid name.
 };
  >>




In article <[EMAIL PROTECTED]>,
   Brandon Orther <[EMAIL PROTECTED]> wrote:
> Check here, I have never messed with it just ran into it the other day.
>  I hope it helps.

> http://www.php.net/manual/en/ref.pspell.php

Sort of.  Thanks go to Kristi as well for spotting this, PHP has so many
bult in functions already!
The only problem is that the site host doesn't have this functionality
installed, and as its a free host, I won't bother asking them.  What I
will probably have to do is make my own function/class using a great big
list of words.  Does anyone know where I could find a text list of every
word in the English language ;-)

Thanks,
Nik





Plain Text Dictionary:
http://www.mso.anu.edu.au/~ralph/OPTED/

Word list:
http://www.antionline.com/archives/text/word-lists/

I just found these by searching through Google.... you may find better.

Kristi




----- Original Message ----- 
From: "Nik Gare" <[EMAIL PROTECTED]>
To: "PHP User Group" <[EMAIL PROTECTED]>
Sent: Saturday, January 20, 2001 8:10 AM
Subject: Re: [PHP] Spell checker?


> In article <[EMAIL PROTECTED]>,
>    Brandon Orther <[EMAIL PROTECTED]> wrote:
> > Check here, I have never messed with it just ran into it the other day.
> >  I hope it helps.
> 
> > http://www.php.net/manual/en/ref.pspell.php
> 
> Sort of.  Thanks go to Kristi as well for spotting this, PHP has so many
> bult in functions already!
> The only problem is that the site host doesn't have this functionality
> installed, and as its a free host, I won't bother asking them.  What I
> will probably have to do is make my own function/class using a great big
> list of words.  Does anyone know where I could find a text list of every
> word in the English language ;-)
> 
> Thanks,
> Nik
> 
> 
> -- 
> 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]
> 





Richard,

THANK YOU!!!

I agree -- this method provides many security vulnerabilities and I appreciate the 
warning.  The database is definitely secure -- from web-surfers and others.  Also, I 
intend to parse the information going into the database myself -- using a simple parse 
engine I will create -- before making it accessible to PHP later.  :)

I have designed a class-oriented language based on PHP, and these are the functions I 
want available to my clients.  I will filter out all other commands that could be 
considered malicious.  They will only have access to the functions and variables used 
in the class language I wrote when I am done.  

What do you think?

Thankz again!

Rob


List:     php-general
Subject:  Re: [PHP] PHP Parse MySQL Field???
From:     "Richard Lynch" <[EMAIL PROTECTED]>
Date:     2001-01-20 9:27:12
[Download message RAW]

>I have a BLOB field in a MySQL database that I want
>to parse into my page using PHP.
>For instance, in this field might be the following:
>
><?  echo "test";  ?>
>
>So when I access this field in PHP I want it to display "test".
>
>Is this possible?

Yeah.  That's called "eval" (short for 'evaluate')

Basically you can make PHP execute arbitrary chunks of more PHP code.

NOTE:  Letting web-surfers insert PHP code into your database to be
evaluated later is really high on the Bad Idea list...  Actually, doing this
on a web-site where you're not pretty sure the database itself is pretty
secure from not only surfers but also other potentially malicious co-users
on the same box...  It's just too easy for them to be able to put mean code
in your database...

http://php.net/eval

I *think* it goes like this:

<?php
    $php = 'echo "Hi";';
    eval($php);
?>

Never used it myself...





Hey!

Is it possible to get the names of the variables allocated in the memory?

thank you,

Rom




WAHOOOOO!!!!!  It works!  Thanks Alex!!!!!!

Fraser

On Fri, 19 Jan 2001, Alex Akilov wrote:

> Fraser,
> 
> Yes, you must set your LD_LIBRARY_PATH prior to running ldd.  In a terminal,
> export
> 
>LD_LIBRARY_PATH=/home/local/java/jdk1.2.2/jre/lib/i386:/home/local/java/jdk1.2.2/jre/lib/i386/classic:/home/local/java/jdk1.2.2/jre/lib/i386/native_threads
> 
> and rerun ldd libjava.so.  If everything works, leave LD_LIBRARY_PATH alone and in
> your php.ini reset your java.library.path to the following:
> 
> java.library.path=/usr/local/lib/php/extensions/no-debug-non-zts-20001214
> 
> Run php <path to php src>/ext/java/jver.php from the command line to verify that
> things are working (that is, provided your php and php.ini are visible from
> whatever directory you're running).
> 
> If everything works, you can try combining LD_LIBRARY_PATH and your
> java.library.path into a single specification (i.e.
> 
>java.library.path=/usr/local/lib/php/extensions/no-debug-non-zts-20001214:/home/local/java/jdk1.2.2/jre/lib/i386:/home/local/java/jdk1.2.2/jre/lib/i386/classic:/home/local/java/jdk1.2.2/jre/lib/i386/native_threads)
> 
> and you should be good to go.  If the latter doesn't work, then your php.ini is
> not being found or java.library.path is not being interpreted correctly.  An
> alternative is to set LD_LIBRARY_PATH in your (root?) profile to include all the
> directories above (or better yet, add them to /etc/ld.so.conf) and restart your
> system.
> 
> Alex
> 
> 
> 





I've a mySQL db with user information (e.g.: name, address, phone, etc.).

I'd like to pre-load an HTML form with the existing user information in 
order to enable the users to update some of the information.

Are there any PHP sample scripts that I may look at to do this?

Thank you!





Do you mean, like if they are editting their profile, their existing one
shows up in the text box?

Here is a chunk of code I wrote to do that this morning:
-------------------------------------------
<?php echo("<form method='POST'
action='upload.php?school=$school&teacherusername=$teacherusername'>"); ?>

<!-- here is the part you might be looking for --!>

<textarea rows="13" name="assignment" cols="51">

<?php
        $DB_NAME = "hwnet";                                //Sets $DB_NAME
equal to "hwnet"

        $connection = mysql_connect("localhost", "youruser", "yourpass");
//Attempts to connect to the server

        $db = mysql_select_db($DB_NAME,$connection) or die("Couldn't select
database!");  //Attempts to connect to the database


        $sql = "SELECT * FROM $TABLE_NAME WHERE username =
'$teacherusername' AND password = '$password'";        // This SQL statement
calls up the table and looks for a username and password match the ones
specified

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

        while ($row = mysql_fetch_array($result)) {
                $assignment = $row['assignment'];
        echo ("Previous assignment:\n $assignment");
}

?>
</textarea>
<!-- end part your probably looking for --!>

  <input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></p>
</form>
-------------------------------------------

What this code did was take the existing info in the database, echo it out
to a array and then display it inside the text box.

- Kath

----- Original Message -----
From: "Anthony Rodriguez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 20, 2001 8:06 AM
Subject: [PHP] Pre-loading HTML form w/ mySQL data


> I've a mySQL db with user information (e.g.: name, address, phone, etc.).
>
> I'd like to pre-load an HTML form with the existing user information in
> order to enable the users to update some of the information.
>
> Are there any PHP sample scripts that I may look at to do this?
>
> Thank you!
>
>
> --
> 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]
>





There you go:

<?php

// DB connection
$dbconnection = mysql_connect ("IP ADDRESS OR HOST+DOMAIN NAME","USERNAME -
DEFULT is root","") or die ("Couldn't connect to Database.");

// Select DB
$database = mysql_select_db ("NAME OF THE DATABASE", $dbconnection) or die
("Couldn't select Database.");

// Query

$query = "SELECT *
                FROM <TABLE>
                WHERE <COND = TRUE>;

// execute query

$query_result = mysql_query ($query,$dbconnection) or die ("Couldn't execute
query in Database.");

// fetching values with while

while ($row = mysql_fetch_array ($query_result)) {
 $VAR1= $row["COLUMN1"];
 $VAR2 = $row["COLUMN2"];

<or a FOR tht will fetch all the values (if is more than one) in $VAR1 and
$VAR2>
}
echo"
<FORM ACTION = \"\">
<INPUT TYPE = text NAME=name VALUE=$VAR1>
<INPUT TYPE=text NAME=telephone VALUE=$VAR2>
</FORM>
?>


----- Original Message -----
From: Anthony Rodriguez <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 20, 2001 8:06 AM
Subject: [PHP] Pre-loading HTML form w/ mySQL data


I've a mySQL db with user information (e.g.: name, address, phone, etc.).

I'd like to pre-load an HTML form with the existing user information in
order to enable the users to update some of the information.

Are there any PHP sample scripts that I may look at to do this?

Thank you!


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





When uploading a file, the built in functions let you get the filename,
size, type.  If the file is an image, is it possible to also get the width
and height of the image?

Right now we are giving input boxes for the user to enter the correct
values, but I'd rather that my code do it for them.  That way I can prevent
images that are too wide, as well as not depend on the uploader being smart
enough to know what the dimensions are.

Can anyone help me out?







Linux , Apache, MySQL

I have a problem in my database(MySQL), this is the senario:
I made an update statement on my table by wrong, then I restor my backup
copy by copying the backup files on the exist ones without stopping the
MySQL.
Now I have problems in searching data:
for example when I made select statement using = , no results, but when
I use %% I can get the result, this thing not happend with all records,
just some of them.
any help will be appreciated.
thanks





    $num=count($bannedwords);
            for($i=0;$i<$num-1;$i++)
            {
                $string =
eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
            }


For whatever reason, no word in $bannedwords will match in the string.  I've
tested it with simple expressions like "\btest\b" and it will not match the
word "test".  Does it have something to do with the 2 "\b"s found in the
code?  After removing them, it replaces all instances of $bannedwords, even
in the middle of words, which is not good.  Any suggestions?


TIA,

Neal





In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
(Team JUMP) wrote:

>    $num=count($bannedwords);
>             for($i=0;$i<$num-1;$i++)
>             {
>                 $string =
> eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
>             }
> 
> 
> For whatever reason, no word in $bannedwords will match in the string.  I've
> tested it with simple expressions like "\btest\b" and it will not match the
> word "test". 

Have you tried it with either "[:space:]$bannedwords[$i][:space:] or 
"\<$bannedwords[$i]\>" yet?  Also, I think using a foreach($bannedwords as 
$current_word) would be a better choice here; more compact, and loops all 
the way to the end of the array even when the numerical index does not 
follow the expected sequence.  (BTW, if you want to stick with the for() 
and you know the index numbers will always be sequentially zero to 
whatever, then your test should be just $i<$num.  Otherwise, you're 
skipping the final loop.)

-- 
CC




Hi.

I'm tearing my hair out trying to get UltraDev to talk to MySQL and I know there are 
some Dreamweaver and MySQL users here.

I think I need some help installing a JDBC driver for this product.

Any help or sympathy is greatly appreciated.

Thanks,
Murph





Hi Debreceni, 

I need to use a template parser, and XTemplate looks like it will do what I
need, but I'm not sure how. I can use mysql_fetch_array to produce an array
of field_name:value.  If I use {field} names in the html template, can I use
XTemplate to take the array and parse?

This is what I have so far - please look at the ASSIGN step

<?
$id=1; //parameter for sql select, determines which row is selected
$user="user";
$pass="pass";
$database="database";
$sql="select * from table where id = $id"; //returns ONE row (id is a PK)

$link_id = mysql_connect($database); //identify connection handle

if (!$link_id)  { die(sql_error()); } //test for connection handle
              
else { mysql_select_db($database, $link_id)  }  //select database

$result = mysql_query($sql, $user, $pass); //return row to php

$page_array = mysql_fetch_array($result);
//this creates array of field name:data,
//eg $page_array[firstfield] has value of 'firstfield' for $id

require "xtpl.p"; //include XTemplate engine
require "html.xtpl"; //html layout file with field names e.g. {firstfield}

$xtpl->assign($page_array); //HELP! How is this step done?
                            //I already have an array that assigns field
                            //names to data elements, how can I skip this?
                            //I don't want to assign each element since then
                            //I would need one .p page for each .xtpl page

$xtpl->parse("main");//replace {field} with matching result row element
$xtpl->out("main");` //send final html page to browser
?>

Does this make sense?

Thanks in advance for any help!

Regards,
Jaxon





require "xtpl.p"; //include XTemplate engine

//don't need this - wrong.
> require "html.xtpl"; //html layout file with field names e.g. {firstfield}

You need to create a new instance of the Xtemplate class so:
//assign the new instance to a variable name you'll use - I called it
$template
//and I specified which "html layout file" to use.

$template = new Xtemplate("html.tpl"); // I name them tpl not xtpl *shrug*

while($row = mysql_fetch_array($result))
{
    $template->assign("FIELD1", $row[fieldname]);
    //FIELD1 being the name you're going to use in the layout file by
{FIELD1}
    //$row being the name of the array you fetched, field name being the
fieldname in the database

    $template->assign("FIELD2", $row[fieldname2]);

    $template->parse("main");//replace {field} with matching result row
element
    $template->out("main");` //send final html page to browser
}



Kristi





Hi Im trying to isntall PHP4 on my Raq 2 but Im not having much luck. I was
wondering if someone here could assist me.

I uploaded apache and configured it and it worked fine. Its running in
/usr/local/apache-x.x.x

I uploaded the php zipped binary by ftp to /home/sites/home
then
mv php-4.0.4.tar.gz /usr/local
then I unpacked it


gunzip php-4.0.4.tar.gz
then
tar vxf php-4.0.4.tar

It unpacked fine. I changed firectories

cd php-4.0.4

I did the configure thing

./configure --with-mysql --with-apache=../apache_1.3.14 --enable-track-vars


I pressed enter and it said loading config.cache and a long list of things
came up. Then it ended and this was what I got.

checking for working makeinfo... found
checking whether to enable maintainer-specific portions of Makefiles... no
checking host system type... mipsel-unknown-linux-gnu
checking for gawk... gawk
checking for bison... bison -y
checking bison version... 1.25 (ok)
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for AIX... no
checking for gcc option to accept ANSI C... none needed
checking for ranlib... ranlib
checking whether gcc and cc understand -c and -o together... yes
checking whether ln -s works... yes
checking for flex... no
checking for lex... no
./configure: flex: command not found
checking for flex... lex
checking for yywrap in -ll... no
checking lex output file root... ./configure: lex: command not found
configure: error: cannot find output from lex; giving up
[root php-4.0.4]#


If anyone can help me i would greatly appreciate it. Thanks.





Reply via email to