OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 3 Oct 2004 10:21:02 -0000 Issue 3031

php-general-digest-helplists.php.net
Date: Sun Oct 03 2004 - 05:21:02 CDT


php-general Digest 3 Oct 2004 10:21:02 -0000 Issue 3031

Topics (messages 198511 through 198532):

PHP5 Type Hints
        198511 by: Gerard Samuel
        198516 by: Curt Zirzow
        198520 by: Gerard Samuel
        198522 by: Aidan Lister
        198523 by: Gerard Samuel

Re: How to load another php page?
        198512 by: Arnold

Re: Including function libraries
        198513 by: Jasper Howard
        198527 by: Marek Kilimajer

Re: Using PHP4 or PHP5
        198514 by: Amit Arora

Re: [PHP-DB] Re: Office document upload to website (and inserting in MySQL if possible)
        198515 by: Bastien Koert

A problem of installation
        198517 by: Teng Wang
        198518 by: Teng Wang
        198519 by: Robert Cummings

please ignore
        198521 by: Jerry M. Howell II

Regular Expression - highlighting
        198524 by: Aidan Lister

How to install php5 on Fedora Core2
        198525 by: Teng Wang
        198531 by: Marek Kilimajer

Retrieving large results from a database ends in memory error.
        198526 by: RaTT
        198528 by: Marek Kilimajer

Re: set multiple variables
        198529 by: argesson
        198532 by: Daniel Schierbeck

Re: How do I produce a random database query for each day or week?
        198530 by: dirk

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

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

attached mail follows:


Im unable to find documentation on this.
Does one exist? If so can you point me to it.
Thanks...

attached mail follows:


* Thus wrote Gerard Samuel:
> Im unable to find documentation on this.
> Does one exist? If so can you point me to it.

I dont think anything officially exist in the manual, yet. The type
hint can only be an Object, and will cause a fatal error if not the
paticular object isn't passed.

class Foo { };

function bar(Foo $foo) { }
  

$a = new Foo();
foo($a);

foo('a string'); // Fatal Error

The most useful use with type hinting can/is used is with
exceptions. The catch() requires a type hint of what class of
exception to catch:

try {
  some_code();
}
catch (CustomException $e) {
}
catch (Exception $e) { // if CustomException isn't thrown
}

Curt
--
The above comments may offend you. flame at will.

attached mail follows:


Curt Zirzow wrote:
> * Thus wrote Gerard Samuel:
>
>>Im unable to find documentation on this.
>>Does one exist? If so can you point me to it.
>
>
> I dont think anything officially exist in the manual, yet. The type
> hint can only be an Object, and will cause a fatal error if not the
> paticular object isn't passed.
>

Thanks. I could have sworn, I saw something somewhere,
that led me to believe that arguments can be casted.
I.E.
function foo(int $foo)
{
     // $foo will be casted as an integer
}

attached mail follows:


Hi Gerald,

If you did see something like that, it was a mistake in our manual :)

I've documented typehinting now, though it will take a while to show up in
the manual.
http://php.net/language.oop5.typehinting

Kind Regards,
Aidan

"Gerard Samuel" <php-generaltrini0.org> wrote in message
news:415F808A.5000604trini0.org...
> Curt Zirzow wrote:
>> * Thus wrote Gerard Samuel:
>>
>>>Im unable to find documentation on this.
>>>Does one exist? If so can you point me to it.
>>
>>
>> I dont think anything officially exist in the manual, yet. The type
>> hint can only be an Object, and will cause a fatal error if not the
>> paticular object isn't passed.
>>
>
> Thanks. I could have sworn, I saw something somewhere,
> that led me to believe that arguments can be casted.
> I.E.
> function foo(int $foo)
> {
> // $foo will be casted as an integer
> }

attached mail follows:


Aidan Lister wrote:
> Hi Gerald,
>
> If you did see something like that, it was a mistake in our manual :)
>
> I've documented typehinting now, though it will take a while to show up in
> the manual.
> http://php.net/language.oop5.typehinting
>

It may have been Example 18-23 at
http://us2.php.net/manual/en/language.oop5.exceptions.php
Thanks for updating the manual...

attached mail follows:


Hi Graham,

This works fine! Without the ob_start and ob_flush commands, all the
header() commands have to be put before the HTML <html> tag, otherwise an
error is displayed about header information that was already sent. Now i put
ob_start() on the first line before <html> and i can put the header()
command everywhere before ob_flush()! Suggestions from others about using
the "include" command doesnt work fine because the php name in the browser
isnt changed to the new php file and that results in some variables like
$_SERVER['PHP_SELF'] keeps pointing to the old php script.
This works fine, but i'm surprised that this was such a difficult question
(i'm not very experienced in PHP). I expected that there would be some kind
of command like "load script.php" to call a new script. Without your
solution you have to let some user constantly push a link or button and
define a new php script to that action.
Thanks for your help!

Regards, Arnold

"Graham Cossey" <grahamcossey.plus.com> wrote in message
news:JGEHJJEPPLDNAPAHKDGGAEBJCJAA.grahamcossey.plus.com...
> For my own clarification, would it not be possible to use output buffering
> and then either redirect to another script using header() or output the
> buffer contents?
>
> <?php
> ob_start();
>
> [php code]
>
> if ($variable = 1)
> header("Location: script1.php");
>
> if ($variable = 2)
> header("Location: script2.php");
>
> ob_flush();
> ?>
>
> thanks
>
> Graham
>
> -----Original Message-----
> From: Marek Kilimajer [mailto:listskilimajer.net]
> Sent: 02 October 2004 21:07
> To: Arnold
> Cc: php-generallists.php.net
> Subject: Re: [PHP] How to load another php page?
>
>
> Arnold wrote:
> > Ok, i can live with it, include works but this doesnt replace the whole
> > running script, only the rest of the script (what is still coming), so
if
> a
> > few things have been written in "a.php", when "include('b.php') is
> executed,
> > this "b.php" does not replace all the (allready written) output of
> "a.php".
>
> That's how the life goes. Once you say something, you can't take it
> back. So think first, then open your mouth :) (put your logic before the
> output).
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


it seems possible that this is the problem, you called it,
"checkLoggedIn()" in your script then tried to call,
"checkloggedin()". Notice the caps aren't there when you tried to call
it.

On Sat, 2 Oct 2004 17:20:07 +0100, Graham Cossey <grahamcossey.plus.com> wrote:
> Do you have <?php and ?> in functions.lib ?
>
>
>
> -----Original Message-----
> From: Andrew W [mailto:awsimple.org]
> Sent: 02 October 2004 16:52
> To: php-gen
> Subject: [PHP] Including function libraries
>
> Ok, I've got a file called functions.lib which contains the following:
>
> function checkLoggedIn()
> {
> return (true);
> }
>
> function Test ($x)
> {
> return ($x * $x);
> }
>
> and a file called test.php which contains the following:
>
> <?php
>
> include 'functions.lib';
>
> if (checkLoggedIn())
> {
> print "Logged in";
> }
> else
> {
> print "Not logged in";
> }
>
> ?>
>
> They're both stored in a directory called 'test' which Ive uploaded to
> my webserver. When I call test.php from my browser I get the following
> output:
>
> function checkLoggedIn() { return (true); } function Test ($x) {
> return ($x * $x); }
> Fatal error: Call to undefined function: checkloggedin() in
> /home/sites/site116/web/test/test.php on line 5
>
> Why can't I call the function defined in the lib file?
>
> Thanks
> AW
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
<<--------------------------------------------------------
Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
------------------------------------------------------->>

attached mail follows:


Jasper Howard wrote:
> it seems possible that this is the problem, you called it,
> "checkLoggedIn()" in your script then tried to call,
> "checkloggedin()". Notice the caps aren't there when you tried to call
> it.

Case does not matter for functions. Only for variable names.

attached mail follows:


If you are going to develop the application on a Object Oriented
Programming, then I would advice you go with PHP 5.

If it is going to a healthy mix of procedural coding and OOP, then I
recommend using PHP 4 right now but gradually upgrade to PHP 5.

Whatever you choose, keep in mind that PHP 5 is not being used widely on
commerical servers as production ready. And it may be couple of months
before that happens. So keep this at the back of your mind as it would
help in you development cycle.

Amit
www.digitalamit.com

Michael Lauzon wrote:
> As I mentioned earlier, I am putting a team together to create a
> web-based RPG, different from the one I am currently playing. Would
> it be better to use PHP4 with it's strong developer base, or the new
> PHP5 which is more object oriented an in my opinion would be easier to
> keep the game up to date?
>

attached mail follows:


here is some code i wrote for a guy.

<?php
session_start();

// redefine the user error constants - PHP 4 only
define("FATAL", E_USER_ERROR);
define("ERROR", E_USER_WARNING);
define("WARNING", E_USER_NOTICE);

// set the error reporting level for this script
error_reporting(FATAL);

//Declarations
$myfile = "";
$article = "";
$username = "";
$FileFlag = 0;
$DBFlag = 0;
$ConStartFlag = 0;
$LoggedInFlag = 0;

//--------------------------------------------------------------------------------------------
//logon the user on
if (($_SESSION['username']=="")&&(!$_POST['submit']=="Log In")){
  logon();
   //show the logon form
  die();
}

//logon form submitted so check button and logon state
if (($LoggedInFlag==0)&&($ConStartFlag==0)&&($_POST['submit']=="Log In")){
  confirm_logon();
}

//--------------------------------------------------------------------------------------------
//main form code

//handle the data inputs
if (!$_POST['submit']=="Submit Entry"){
  show_form();
  die();
}else{
  $article = $_POST['article'];
}//end if

  //check for the presence of a file
  $tempfile = $_FILES['userfile']['tmp_name'];
   //get the temporary file name from the upload dir
  if (is_uploaded_file($tempfile)){
    upload();
  }else{
    $FileFlag = 0;
  }//end if

  //check there is a value for article
  if ($article!=''){
    echo "Processing entry.<br>";
    load_db($article);
  }

  //article submission confirmed and records / files updated uploaded
  if ($DBFlag == 1){
    confirmation();
  }

function show_form()
{
?>
  <form enctype="multipart/form-data" action="<? echo
$_SERVER['PHP_SELF'];?>" method="post">
   <table><tr><td valign="top">
   Composition:</td><td><textarea name="article" rows="25"
cols="100"></textarea></td>
   <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
   </tr><tr><td align="center" colspan="2">Send this file: <input
name="userfile" type="file" /></td>
   </tr><tr><td align="center" colspan="2"><input type="submit"
name="submit" id="submit" value="Submit Entry" /> </td></tr></table
  </form>

<?
}

function upload()
{
  // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used
instead
  // of $_FILES.

  global $article, $FileFlag,$myfile;

  $uploaddir = '../bastien/uploads/';
      //change to match your dir
  $uploadfile = $uploaddir . $_FILES['userfile']['name'];
  $myfile = $_FILES['userfile']['name'];
  //echo "Filename is:".$myfile."<br>";

  print "<pre>";
  //check the file extension (only doc allowed) and check the mime type of
the file
  if ($_FILES['userfile']['type']!='application/msword'){
    echo "filetype=".strtolower(substr($_FILES['userfile']['name'],-3));

    if (strtolower(substr($_FILES['userfile']['name'],-3))=="doc"){

      //check the file size
      if ($_FILES['userfile']['size']<30000){
        if (copy($_FILES['userfile']['tmp_name'], $uploadfile)){
       //windows
        //if (move_uploaded_file($_FILES['userfile']['tmp_name'],
$uploadfile)) { //unix
           $FileFlag = 1;

        } //end if copy file
      }//end if file size
    }//end if file type
  }else{
    show_form($article);
    die("File is of the wrong format and has been rejected. Please try
again.");
  }
  print "</pre>";
}//end function

function load_db($article)
{
  global $DBFlag, $myfile, $FileFlag;
//get the data to load into the db
$sql = "";
$time_out = "";
$time_out = date("Y-m-D H:i:s");

//get the connection info
require("dbconng.php");
  //create and run the query to load the data into the db
  $sql = "update contest set article = '$article', time_out = now() ";

  if ($FileFlag == 1){
     $sql.=", file_name = '$myfile' ";
  }
  $sql.= "where user_id=".$_SESSION['user_id'];
  echo $sql;
  $result = mysql_query($sql,$conn)or die ("Can't insert data because
".mysql_error());

  if (!$result){
    echo "There was an error with the database. Hit the back button and try
again.";
  }else{
    $DBFlag = 1;
  }//end if

}//end function

function confirmation()
{
  global $FileFlag, $DBFlag;
  //show the confirmation screen
  if (($FileFlag == 1) && ($DBFlag ==1)){
    $msg = "File and contest entry have been successfully uploaded.<br
/>Good luck in the contest";
  }else{
    $msg = "Contest entry have been successfully uploaded.<br />Good luck in
the contest";
  }

  echo $msg;
  session_destroy();

} //end function

function logon()
{
  //show the logon form
  echo "<div style=\"position:absolute; top:250; left:300; width:300;
height:250;\">
          <center><h2>Rich's Writing Club Contest</h2></center>
          <form name=\"logon\" action=\"".$_SERVER['PHP_SELF']."\"
method=\"post\">
            <table>
               <tr><td width=\"100\">User Name:</td><td><input type=\"text\"
name=\"username\" size=\"20\"></td></tr>
               <tr><td>Password :</td><td><input type=\"password\"
name=\"pass\" size=\"20\"></td></tr>
               <tr><td colspan=\"2\" align=\"center\"><input type=\"submit\"
name=\"submit\" value=\"Log In\"></td></tr>
            </table>
          </form>
        </div>";

}//end function

function confirm_logon()
{
  global $ConStartFlag;
  //get the connection info
  require("dbconng.php");

  //do the logon check
  $username = "";
  $user_id = "";
  $pass = "";
  $sql = "";
  $sql2 = "";
  $time_in = "";
  $time_in = date("Y-m-D H:i:s");

  //assume only alpha and numeric chars allowed in username & passwords
  
if((eregi("[[:alnum:]]",$_POST['username']))&&(eregi("[[:alnum:]]",$_POST['pass']))){
     $username = $_POST['username'];
     $pass = $_POST['pass'];

  }else{

     logon();
     die("Invalid login attempt");
  }//end if

  $sql = "select user_id from users where user_name = '$username' and pass =
'".md5($pass)."'";

  $result = mysql_query($sql,$conn)or die ("Can't insert data because
".mysql_error());

  if (mysql_num_rows($result)==1){
    $_SESSION['username'] = $username;
    //get the user id from the db
    while ($row = mysql_fetch_array($result)){
      $_SESSION['user_id'] = $row['user_id'];
      $user_id = $row['user_id'];

    }//end while
  }else{
      logon();
      die("Invalid login attempt!");
  }//end if

  if ($user_id){
    //sql to register the user as logged on and the time they signed in
    $sql2 = "insert into contest (user_id,time_in) values ($user_id,
now())";
    echo $sql2;
    $result2 = mysql_query($sql2,$conn)or die ("Can't insert data because
".mysql_error());

    if (!$result2){
      echo "There was an error. Try again.";
      if (mysql_errno($result)==1062){
         echo "Our records indicate that you have already tried to submit
for the contest.";
         $sql_check = "select * from contest where user_id = $user_id";
         $result3 = mysql_query($sql_check,$conn)or die ("Can't insert data
because ".mysql_error());
         if ($result3){
            while ($rows= mysql_fetch_array($result3)){
               $article = $rows['article'];
               $file_name = $rows['file_name'];
               $user = $rows['user_id'];
            }//end while
         }
         }
      logon();
      die();
    }else{
      //start the contest and show the form
      $ConStartFlag = 1;
      show_form();
    }//end if
  }//end if

}//end function

?>

bastien

>From: "Phill" <phillblack-heart.co.uk>
>To: php-dblists.php.net, php-generallists.php.net
>Subject: [PHP-DB] Re: Office document upload to website (and inserting in
>MySQL if possible)
>Date: Fri, 1 Oct 2004 17:07:33 +0100
>
>"Pugi!" <geenzever.pugilatoryahoo.com> wrote in message
>news:c2ig06$1kq$1news.worldonline.be...
> > Hi,
> >
> > I would like to upload office-document (doc, xls, ...) using a form to a
> > website (apache, php, mysql) in a specific directory and if possible
> > insert
> > it into a table (MySQL-db). Is this possible. If yes, how ? You don't
>have
> > to explain it in detail, a link to a website or online manual or example
> > is
> > fine.
> >
> > Thanks,
> >
> > Pugi!
> >
> >
> >
> > Please reply to group or to pugilator at yahoo dot com
> >
>
>I think I get what you want to do, do you want to have a form on a webpage,
>where you specify the path of it on that pc, and then be able to upload it
>to a folder on the server. Then, you store the details, such as original
>filename, current filename, location etc. in the database.
>
>I know this is possible, but I've never managed to do it myself. Try
>looking
>in PHP and MySQL, it's by Larry Ullman and is published by Peachpit Press.
>There is something towards the back of the book about file uploads, and it
>gives an example of a solution like I explained above
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

_________________________________________________________________
Take charge with a pop-up guard built on patented Microsoft® SmartScreen
Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
  Start enjoying all the benefits of MSN® Premium right now and get the
first two months FREE*.

attached mail follows:


I met with a problem when installing php5.0.0 on my Federo Core 2.0 system.

I use the default settings:
./configure
make
make install

Everything is ok, but when I test my phpinfo(),it always shows the
4.3.8 version. Yet, when I type the following command
php -v
to show the version of php, it's 5.0.0

What's the problem? Any kindly help would be appreciated.

attached mail follows:


I met with a problem when installing php5.0.0 on my Federo Core 2.0 system.

I use the default settings:
./configure
make
make install

Everything is ok, but when I test my phpinfo(),it always shows the
4.3.8 version. Yet, when I type the following command
php -v
to show the version of php, it's 5.0.0

What's the problem? Any kindly help would be appreciated.

attached mail follows:


On Sun, 2004-10-03 at 00:05, Teng Wang wrote:
> I met with a problem when installing php5.0.0 on my Federo Core 2.0 system.
>
> I use the default settings:
> ./configure
> make
> make install
>
> Everything is ok, but when I test my phpinfo(),it always shows the
> 4.3.8 version. Yet, when I type the following command
> php -v
> to show the version of php, it's 5.0.0
>
> What's the problem? Any kindly help would be appreciated.

Where are you loading phpinfo()? If it is in browser then there's a good
chance you've only built the cgi/cli version and not the module. The
module version needs the --with-apxs flage enabled.

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. |
`------------------------------------------------------------'

attached mail follows:


just testing maildrop please ignore :)

attached mail follows:


Hello list,

I'm pretty terrible with regular expressions, I was wondering if someone
would be able to help me with this
http://paste.phpfi.com/31964

The problem is detailed in the above link. Basically I need to match the
contents of any HTML tag, except a link. I'm pretty sure a lookbehind set is
needed in the center (%s) bit.

Any suggestions would be appreciated, but it's not quite as simple as it
sounds - if possible please make sure you run the above script and see if it
"PASSED".

Here's a little gui to make it easier to test:
http://aidan.dotgeek.org/test_hl.php

Thanks in advance,
Aidan

attached mail follows:


I have some difficulties when installing php5.0.2 on FC2

I used the default settings:
./configure --with-apxs2=/usr/sbin/apxs
build
build install

The installation is complete but when I test phpinfo() in a .php file from browser, the browser says "Can't find the
server"

My FC2 is fully installed and I don't know why the php
module doesn't work.

I doubt if there is some manual settings are need during the configuration/make/make install, or there is some setting
after the installation such as change the default httpd.conf or /etc/php.ini

I type php -v, the version is fine, php -i is also correct.
But I can't make it work through http.

Thanks in advance for any kindly help!

                            eruisi
                            10/03/2004
                            04:00:59

attached mail follows:


Teng Wang wrote:
> I have some difficulties when installing php5.0.2 on FC2
>
> I used the default settings:
> ./configure --with-apxs2=/usr/sbin/apxs
> build
> build install
>
> The installation is complete but when I test phpinfo() in a .php file from browser, the browser says "Can't find the
> server"

Can't find the SERVER. Make sure apache is running.

>
> My FC2 is fully installed and I don't know why the php
> module doesn't work.
>
> I doubt if there is some manual settings are need during the configuration/make/make install, or there is some setting
> after the installation such as change the default httpd.conf or /etc/php.ini

If you had php4 installed, remove php4 stuff from httpd.conf

>
> I type php -v, the version is fine, php -i is also correct.
> But I can't make it work through http.
>
> Thanks in advance for any kindly help!
>
>
> eruisi
> 10/03/2004
> 04:00:59
>

attached mail follows:


Hi Guys

I am trying to retrieve over 5000 rows from a mysql database, i have
to use a "SELECT *" query as i am required to use all the fields for
display.

Everytime i try to run the code below i get a Allowed memory size of
10485760 bytes exhausted (tried to allocate 40 bytes). Now if i change
php's memory limit in the php.ini file to something like 80MB then its
fine, but i can't be guarantied that the person who this code is for
will be able or willing to access their php.ini file.

Basically what i am asking is there a better way to write this query
so i can still retrieve all the results from the database without
running into memory issues ? should i break it up into chunks and put
it through a loop ?

Any assitance on retriving large amout of info from a db would be most
appreciated.

THis is the basic code i am using:

$q = "SELECT * FROM `users` ORDER BY UserID";
$r = mysql_query($q) or die("There has been a query error: ".mysql_error());
if($getR = mysql_fetch_array($r,MYSQL_ASSOC)){
       do {
               $userarray[] = $getR;
       }
       while($getR = mysql_fetch_array($r));
       echo 'Done retrieved '.count($getR).' records.';
}
else {
       echo 'there has been an error retrieving the results.';
}

Thanks
Jarratt

attached mail follows:


Use mysql_unbuffered_query()

RaTT wrote:
> Hi Guys
>
> I am trying to retrieve over 5000 rows from a mysql database, i have
> to use a "SELECT *" query as i am required to use all the fields for
> display.
>
> Everytime i try to run the code below i get a Allowed memory size of
> 10485760 bytes exhausted (tried to allocate 40 bytes). Now if i change
> php's memory limit in the php.ini file to something like 80MB then its
> fine, but i can't be guarantied that the person who this code is for
> will be able or willing to access their php.ini file.
>
> Basically what i am asking is there a better way to write this query
> so i can still retrieve all the results from the database without
> running into memory issues ? should i break it up into chunks and put
> it through a loop ?
>
> Any assitance on retriving large amout of info from a db would be most
> appreciated.
>
> THis is the basic code i am using:
>
> $q = "SELECT * FROM `users` ORDER BY UserID";
> $r = mysql_query($q) or die("There has been a query error: ".mysql_error());
> if($getR = mysql_fetch_array($r,MYSQL_ASSOC)){
> do {
> $userarray[] = $getR;
> }
> while($getR = mysql_fetch_array($r));
> echo 'Done retrieved '.count($getR).' records.';
> }
> else {
> echo 'there has been an error retrieving the results.';
> }
>
> Thanks
> Jarratt
>

attached mail follows:


try this:
if ($REMOTE_ADDR == "212.3.54.65" && $REMOTE_ADDR == "212.3.54.66")

Joe Szilagyi wrote:
> Hi, I have this working:
>
>
> if ($REMOTE_ADDR == "212.3.54.65") {
> header("Location: http://www.google.com/search?&q=huzzah");
> Redirect browser
> exit;
> }
>
>
> But I want to specify multiple IPs. What's the best recommended way for
> doing that?
>
>
> thanks
> Joe

attached mail follows:


Argesson wrote:
> try this:
> if ($REMOTE_ADDR == "212.3.54.65" && $REMOTE_ADDR == "212.3.54.66")
>
> Joe Szilagyi wrote:
>
>> Hi, I have this working:
>>
>>
>> if ($REMOTE_ADDR == "212.3.54.65") {
>> header("Location: http://www.google.com/search?&q=huzzah");
>> Redirect browser
>> exit;
>> }
>>
>>
>> But I want to specify multiple IPs. What's the best recommended way for
>> doing that?
>>
>>
>> thanks
>> Joe

Make that:
if ($REMOTE_ADDR == "212.3.54.65" || $REMOTE_ADDR == "212.3.54.66")

attached mail follows:


My idea on your problem would be to use a random sql-query selecting a
cd from your database.

SELECT * FROM my_table ORDER BY RAND() LIMIT 1;

This could be placed in a script that is executed only by the first
user in a week and the result is stored e.g. in a text file and
included in any later call of your website. It's too early in the
morning for details (I just stood up), but if you have questions about
realization please ask.

Dirk.

On Fri, 01 Oct 2004 15:45:54 +0200, -{ Rene Brehmer }-
<metalbunnymetalbunny.net> wrote:
> At 10:31 01-10-2004, Graham Cossey wrote:
> >A couple of thoughts:
> >
> >As you want to cycle through the list rather than randomly (with repetition)
> >picking from the list, have you considered storing the last CD shown details
> >in the DB?
> >
> >If each CD has a sequential ID then each week (or day) you increment the
> >number which will determine what CD is shown. If the incremented CD id
> >exceeds the highest id in the DB, restart back at the first id.
>
> Just incrementing the ID is not a good idea. It does not allow for the
> flexibility required if you suddenly delete a CD in the middle. So it'd be
> better doing something like "SELECT * FROM cds WHERE `CDid`>'$LastCDid' ".
> Then obviously you'd need to check if the last shown was the last in the
> base, you'd get 0 rows. But this can be circumvented by just checking the
> number of rows returned, and if the rowcount is < 1, simply do a new SELECT
> with CDid > 0.
>
> >You could also include a column (or two) in the CD info table to record when
> >it was last displayed and check that this is > 29 days ago.
>
> I agree that this would be the easiest way. On every display you do an
> update to store the date, then on each page load just calculate how long
> ago the CD show must've been shown last.
>
> >What about cookies? Each visitor could then have their own 'cycle' through
> >the list.
>
> This is a per need basis. With the "last shown date" you don't need the
> cookies.
>
> --
> Rene Brehmer
> aka Metalbunny
>
> If your life was a dream, would you wake up from a nightmare, dripping of
> sweat, hoping it was over? Or would you wake up happy and pleased, ready to
> take on the day with a smile?
>
> http://metalbunny.net/
> References, tools, and other useful stuff...
> Check out the new Metalbunny forums at http://forums.metalbunny.net/
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Try http://einx.dyndns.org