php-general Digest 18 Dec 2005 14:29:38 -0000 Issue 3857

Topics (messages 227583 through 227599):

Re: Function Overloading
        227583 by: tg-php.gryffyndevelopment.com
        227596 by: Labunski

Re: Problem on Instalation ~ several module unable to downl oad
        227584 by: Bagus Nugroho

Someone please help me with this PHP script.
        227585 by: Erik Johnson
        227586 by: Robert Cummings
        227587 by: Wolf
        227592 by: M. Sokolewicz

Re: Fatal error 'Unable to read from thread kernel pipe' when using mail() 
function
        227588 by: Curt Zirzow

Re: Weird html - No "real" <cr>
        227589 by: Curt Zirzow

Need help with modifying values
        227590 by: Anasta
        227591 by: Matt Stone
        227593 by: programmerdelhi.gmail.com

Re: Random Images with no duplicates?
        227594 by: Silvio Porcellana [tradeOver]
        227595 by: Silvio Porcellana [tradeOver]

insert to DB
        227597 by: Anasta
        227598 by: Brian V Bonini

Re: PHP and Apache 2.2.0
        227599 by: Kevin McBride

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 ---
If all you want to do is pass an unknown number of arguments to a function, 
this looks like it demonstrates what you're doing:

<?php
function foo()
{
   $numargs = func_num_args();
   echo "Number of arguments: $numargs\n";
}

foo(1, 2, 3);    // Prints 'Number of arguments: 3'
?> 

Found it at:
http://www.php.net/manual/en/function.func-num-args.php


= = = Original message = = =

"PHP does not support function overloading."
So, is there any other way of getting a number of parameters(variables) 
passed to a function?

aka.
function fruits($apple, $banana, $kiwi, $grape)

#should (somehow) output 4



OK. if it was an array, than I could use count($array), but now I'm stuck!

Thanks in advance! 

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


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
Thank you very much. This is exactly what I wanted to do. 

--- End Message ---
--- Begin Message ---
Sorry, just reply it..
 
I was tring to put php.ini on c:\php or c:\windows, still fail to load several 
modules.
 
Then, I'm check to load module by module and notified almost all of database 
module(mysql, mysqli,oracle,sybase,oci) unable to load when php start_up.(only 
postgreSQL is able to load).
Meanwhile, other database module such as (mbstring, gd etc) is able to load.
 
Anyone have experience like this?
 
Thanks in advance
 
Note :
System configuration :
PHP : PHP5.05
OS  : XP SP2
Server : Apache 2.0
Database : MySQL4 and MySQL5

________________________________

From: Jay Blanchard [mailto:[EMAIL PROTECTED]
Sent: Sat 10-Dec-2005 04:14
To: Bagus Nugroho; [email protected]
Subject: RE: [PHP] Problem on Instalation ~ several module unable to downl oad



[snip]
Yes,
all requested module is put on same folder which module which succesfully
load.

But, I don't understand why they say the module is not found?

What operating system are you using?
{/snip]

Sorry, found the original post. Can you send the snippet for the php.ini
where you set the extensions directory?




--- End Message ---
--- Begin Message ---
I do not know why this isn't working, but it would be very helpful if
someone looked over it.

<?
$defaultpage = "http://lom.game-host.org/uploads/erik/";;

If($page == NULL) {
    $page = "one";
}

if($page == "one") {
    Echo "<html><head><title>Page One</title></head><body>It works!!<br><a
href=\"" . $defaultpage . "index.php?page=two\">Nice...</a></body></html>";
}

elseif($page == "two") {
    Echo "<html><head><title>Page Two</title></head><body>This is page " .
$page . " -- <a href=\"" . $defaultpage . "index.php
?page=\">;D</a></body></html>";
}

elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
    Echo "<html><head><title>Undefined!</title></head><body>page isn't
defined correctly!</body></html>";
}

if($page == "") {
    Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage . ">Main
Page..</a>";
}
?>

Thank you,

Erik Johnson

--- End Message ---
--- Begin Message ---
On Sat, 2005-12-17 at 23:05, Erik Johnson wrote:
> I do not know why this isn't working, but it would be very helpful if
> someone looked over it.
> 
> <?
> $defaultpage = "http://lom.game-host.org/uploads/erik/";;
> 
> If($page == NULL) {
>     $page = "one";
> }

What is this magical $page variable? Did you conjure it from thin air?
Or are you one of those coders still using a years old deprecated
feature called register_globals who just upgraded their version of PHP
to a version that disables it by default? Since you're the latter (yes I
can read minds from afar), then what you really want is the following
before you start using $page:

    $page = isset( $_GET['page'] ) ? $_GET['page'] : null;

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
What is it doing, or not doing?

Try changing the <? to <?php and see if that works.

Robert

Erik Johnson wrote:
> I do not know why this isn't working, but it would be very helpful if
> someone looked over it.
> 
> <?
> $defaultpage = "http://lom.game-host.org/uploads/erik/";;
> 
> If($page == NULL) {
>     $page = "one";
> }
> 
> if($page == "one") {
>     Echo "<html><head><title>Page One</title></head><body>It works!!<br><a
> href=\"" . $defaultpage . "index.php?page=two\">Nice...</a></body></html>";
> }
> 
> elseif($page == "two") {
>     Echo "<html><head><title>Page Two</title></head><body>This is page " .
> $page . " -- <a href=\"" . $defaultpage . "index.php
> ?page=\">;D</a></body></html>";
> }
> 
> elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
>     Echo "<html><head><title>Undefined!</title></head><body>page isn't
> defined correctly!</body></html>";
> }
> 
> if($page == "") {
>     Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage . ">Main
> Page..</a>";
> }
> ?>
> 
> Thank you,
> 
> Erik Johnson
> 

--- End Message ---
--- Begin Message ---
Aside from the 20 suggestions you've already got, let me add this one:
elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {

     Echo "<html><head><title>Undefined!</title></head><body>page isn't
 defined correctly!</body></html>";
 }

is useless code. Why?
$page = null; never happens (you made sure of that further up the page).
$page = "one"; never happens (you already pulled that one out earlier).
$page = "two"; never happens (you already pulled that one out earlier).

So... if *any* of those returns true you show an error... may I suggest just changing it to an else instead? a lot more logical(!). Besides that, were you to move this to its own if() you'd notice it would always display because if the page is "one" it *can not* be "two" or null, and will thus be displayed. Which means that you'd have an error which would always display...

oh well, ignore my rant and first make sure to follow the suggestions provided by others

- tul
Wolf wrote:
What is it doing, or not doing?

Try changing the <? to <?php and see if that works.

Robert

Erik Johnson wrote:

I do not know why this isn't working, but it would be very helpful if
someone looked over it.

<?
$defaultpage = "http://lom.game-host.org/uploads/erik/";;

If($page == NULL) {
   $page = "one";
}

if($page == "one") {
   Echo "<html><head><title>Page One</title></head><body>It works!!<br><a
href=\"" . $defaultpage . "index.php?page=two\">Nice...</a></body></html>";
}

elseif($page == "two") {
   Echo "<html><head><title>Page Two</title></head><body>This is page " .
$page . " -- <a href=\"" . $defaultpage . "index.php
?page=\">;D</a></body></html>";
}

elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
   Echo "<html><head><title>Undefined!</title></head><body>page isn't
defined correctly!</body></html>";
}

if($page == "") {
   Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage . ">Main
Page..</a>";
}
?>

Thank you,

Erik Johnson


--- End Message ---
--- Begin Message ---
On Fri, Dec 16, 2005 at 03:07:20PM +0000, Stut wrote:
> Hi All,
> 
> I've just upgraded the PHP port installation on my server to v4.4.1 and 
> the mail function has stopped working. I created a script that simply 
> calls the mail function to send a test email ad this is what I get when 
> I run it...
> 
> [EMAIL PROTECTED]:~$ php test.php
> Fatal error 'Unable to read from thread kernel pipe' at line 1100 in 
> file /usr/src/lib/libc_r/uthread/uthread_kern.c (errno = 0)
> Abort trap (core dumped)

This is a new one for me.

> 
> I've googled for this error and all references I found that related to 
> PHP basically say that it's due to Apache and PHP being compiled in 
> different threading modes. This cannot be the case in this instance 
> since Apache is using the preform MPM and even if it wasn't it's 
> happening on the CLI where Apache is not involved.

I'm thinking it has to do with the threading modes handled by the
bsd kernel: libkse, libc_r, libthr. If say apache was compiled with
libkse and php with libc_r, this is the kind of threading conflict
i think could occure.


> Any clues people might have as to the cause of this problem would be 
> gratefully received.
> 
> FYI: OS is FreeBSD v5.2 and Apache if v2.0.55

If you are doing this on a cvsup'd port, there could have been
major changes, you are using the portupgrade tool to install these
ports right?

I would search the bsd-ports or bsd-general mailing lists to see if
this there is anything related, and also you could try the bsd
specific google search: http://google.com/bsd

HTH,

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Sat, Dec 17, 2005 at 12:03:02AM +0100, Gustav Wiberg wrote:
> Hi there!
> 
> Why do I get this kind of ... why don't <cr> work? There is now <newline> 
> as when you view source in an ordinary html-file... I hope you guys 
> understand what I mean...
> 
> 
> DOWN BELOW IS THE PHP CODE! :-)

Are you serious?!  posting 750+ lines of this, i gave up while
seeing the same line repeated 10 times.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
The first script works ' modify_values.php' showing the values and a modify 
link next to each but the next script it parses to  'modify_values2.php' is 
obviously not working. I have tried to modify it from another script and 
cant get it to pass the correct variables-- it always shows the first row in 
the database . Any help appreciated.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modify_values.php

<?php
include("connect.php");
$sql = "Select * from leaderboard";
$result = mysql_query($sql);
?>
<br>
<br>

<body bgcolor="#FFFFFF" text="#666666" link="#666666">


<table width="461" border="1" align="center" cellpadding="2" cellspacing="0" 
bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
 <td width="206" height="25" align="center" bordercolor="#FFFFFF" ><div 
align="left"><b>Title</b></div></td>
 <td width="165" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><div 
align="left"><b>Rating</b></div></td>
 <td width="70" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF"></td>

</tr>
<?php
while ($myrow = mysql_fetch_array($result)) {

 echo "<tr><td>" . $myrow['Name'] . "</td>";
 echo "<td>" . $myrow['Rating'] . "</td>";
 echo "<td bgcolor='cyan'> <a href='modify_values2.php?id=" . $myrow['ID'] . 
"'>Modify</a></td></tr>";
}
?>
</table>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



modify_values2.php

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


<?php
include("connect.php");



$sql = "Select * from leaderboard ";
$result = mysql_query($sql);

$myrow = mysql_fetch_array($result);

 $Name = $myrow['Name'];
 $Rating = $myrow['Rating'];

?>
<form name="form1" method="POST" action="update_values.php">

<center>
    <table border="1">
      <tr>
        <td><b>Title</b></td>
        <td> <INPUT TYPE=TEXT SIZE="50" NAME="Name" VALUE="<?php echo 
$Name;?>">
        </td>
      </tr>
      <tr>
        <td><b>Rating</b></td>
        <td> <INPUT TYPE=TEXT SIZE="50" NAME="Rating" VALUE="<?php echo 
$Rating;?>">
        </td>
      </tr>
      </table>
  </center>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br><center><input type="submit" name="Update" value="Update"> &nbsp; <input 
type="submit" name="Delete" value="Delete"></center>
</form>
</body>
</html> 

--- End Message ---
--- Begin Message ---
There's a big difference between the first and second scripts your using.
The second one isn't using a while loop so will only return the first row in
the recordset. See below.

HTH

Cheers
Matt

----- Original Message ----- 
From: "Anasta" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, December 18, 2005 8:21 AM
Subject: [PHP] Need help with modifying values



> while ($myrow = mysql_fetch_array($result)) {
>
>  echo "<tr><td>" . $myrow['Name'] . "</td>";
>  echo "<td>" . $myrow['Rating'] . "</td>";
>  echo "<td bgcolor='cyan'> <a href='modify_values2.php?id=" . $myrow['ID']
.
> "'>Modify</a></td></tr>";
> }
> ?>
+++++++++++++++++++++++++++++
>
>
> $myrow = mysql_fetch_array($result);
>
>  $Name = $myrow['Name'];
>  $Rating = $myrow['Rating'];
>
> ?>

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

I am looking for a full time online Job. Please have a look at my CV at the
below link. any one looking for freelancer or permanent employee 8 hours a
day, 5 days a week.

Salary 1000 USD per month

www.bsdinfotech.com/loveneesh1.htm

Regards,



----- Original Message ----- 
From: "Matt Stone" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: 18 December 2005 2:49
Subject: Re: [PHP] Need help with modifying values


> There's a big difference between the first and second scripts your using.
> The second one isn't using a while loop so will only return the first row
in
> the recordset. See below.
>
> HTH
>
> Cheers
> Matt
>
> ----- Original Message ----- 
> From: "Anasta" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Sunday, December 18, 2005 8:21 AM
> Subject: [PHP] Need help with modifying values
>
>
>
> > while ($myrow = mysql_fetch_array($result)) {
> >
> >  echo "<tr><td>" . $myrow['Name'] . "</td>";
> >  echo "<td>" . $myrow['Rating'] . "</td>";
> >  echo "<td bgcolor='cyan'> <a href='modify_values2.php?id=" .
$myrow['ID']
> .
> > "'>Modify</a></td></tr>";
> > }
> > ?>
> +++++++++++++++++++++++++++++
> >
> >
> > $myrow = mysql_fetch_array($result);
> >
> >  $Name = $myrow['Name'];
> >  $Rating = $myrow['Rating'];
> >
> > ?>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Jared Williams wrote:
> Hi,
>       Just unset the ones you've picked
>  
> <?php
> #random images example
> #this is your file
> $file = "images.txt";
> #open the file
> $openFile = file($file);
> #generate a random number
> srand((double)microtime()*1000000);
> #get one of the entries in the file
> for ($i = 0; $i < 10; ++$i)
> {
>    $r = array_rand($openFile);
>    $random_image = $openFile[$r]; 
>    echo "<img src='$random_image' height='170'  width='100'></img>";
>    unset($openFile[$r]);
> }
> ?>
> 
> Jared
> 

Sorry if I jump in late in this thread, but wouldn't this work?

<code>
        $file = "images.txt";
        $openFile = file($file);
        $num_images = 10;
        # don't need this is PHP > 4.2.0
        srand((float) microtime() * 10000000);
        $random_keys = array_rand($openFile, $num_images);
        foreach ($random_keys as $random_key) {
                echo "<img src='$random_image' height='170'  
width='100'></img>";
        }
</code>

array_rand: http://php.net/array_rand

Maybe I'm missing something... Anyway, cheers everybody!

Silvio

-- 
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

--- End Message ---
--- Begin Message ---
Silvio Porcellana [tradeOver] wrote:
> 
> <code>
>       $file = "images.txt";
>       $openFile = file($file);
>       $num_images = 10;
>       # don't need this is PHP > 4.2.0
>       srand((float) microtime() * 10000000);
>       $random_keys = array_rand($openFile, $num_images);
>       foreach ($random_keys as $random_key) {
>               echo "<img src='$random_image' height='170'  
> width='100'></img>";

ops, sorry, that obviously should be:
        echo "<img src='" . $openFile[$random_key] . "' height='170'
width='100'></img>";

>       }
> </code>

Sorry about this!

Silvio

-- 
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

--- End Message ---
--- Begin Message ---
It just wont insert new data into DB--any ideas as i have gone over and 
over.



<?
mysql_connect("localhost","anasta","silteren");

mysql_select_db("mytipperv1");

if(!isset($cmd))
{
   $result = mysql_query("select * from leaderboard order by ID");

   while($r=mysql_fetch_array($result))

   {
      //grab the title and the rating of the entry
      $id=$r["ID"];//take out the id
   $Name=$r["Name"];//take out the Name
   $Rating=$r["Rating"];//take out the Rating


    echo "$Name <a href='edit.php?cmd=edit&ID=$id'> Edit</a><br>";


    }
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
   if (!isset($_POST["submit"]))
   {
      $id = $_GET["ID"];
      $sql = "SELECT * FROM leaderboard WHERE ID=$id";
      $result = mysql_query($sql);
      $myrow = mysql_fetch_array($result);
      ?>

      <form action="../craigs_DB/edit.php" method="post">
      <input type=hidden name="ID" value="<?php echo $myrow["ID"] ?>">

      Name: <INPUT TYPE="TEXT" NAME="Name"  VALUE="<?php echo $myrow["Name"] 
?>" SIZE=15 maxlength="15"><br><br>
      Rating: <INPUT TYPE="TEXT" NAME="Rating"  VALUE="<?php echo 
$myrow["Rating"] ?>" SIZE=3 maxlength="3"><br><br>
      <input type="hidden" name="cmd" value="edit">
      <input type="submit" name="submit" value="submit">
      </form>

<? } ?>
<?
   if ($_POST["$submit"])
   {
      $Name = $_POST["Name"];
   $Rating = $_POST["Rating"];

   $sql = "UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE 
ID=$id";
      //replace news with your table name above
      $result = mysql_query($sql);
      echo "Thank you! Information updated.";
 }
}
?>

--- End Message ---
--- Begin Message ---
On Sun, 2005-12-18 at 07:41, Anasta wrote:
> It just wont insert new data into DB--any ideas as i have gone over and 
> over.

Your not doing any inserts, two selects and one update... 

insert in t1 values('foo','bar','1 1 2 3 5 8 13');


-- 

s/:-[(/]/:-)/g


Brian        GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

--- End Message ---
--- Begin Message ---
Manuel Lemos wrote:
I built PHP 5.1 with Apache 2.2 following these instructions and it
works:

http://ww.php.net/manual/en/install.unix.apache2.php


Seems to work now... maybe Apache meant that the 2.0 vs. 2.2 module info
was valid only for precompiled binaries...

--- End Message ---

Reply via email to