php-general Digest 26 Aug 2007 18:18:38 -0000 Issue 4983

Topics (messages 261282 through 261298):

Re: Calling functions which names are inside a variable
        261282 by: Robert Cummings
        261284 by: Robert Keizer
        261286 by: Sanjeev N

determine which string is longer and then what is different in that string
        261283 by: Richard Kurth
        261285 by: Robert Keizer
        261287 by: Sanjeev N

Re: Does JavaScript not work in php web file?
        261288 by: Patrik Hasibuan
        261298 by: Sanjeev N

help with session
        261289 by: Jason Cartledge
        261290 by: mike
        261291 by: Wouter van Vliet / Interpotential

text to HTML
        261292 by: Ron Piggott
        261294 by: Bastien Koert

upload temp dir in vhost env.
        261293 by: jekillen
        261295 by: brian
        261296 by: Ludovic André

How do I  delete a  composite key?
        261297 by: nitrox .

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
On Sat, 2007-08-25 at 23:46 -0600, Robert Keizer wrote:
> I am currently working on a module testing class, I can't seem to find the  
> correct syntax. Here is an example of the problem:
> 
> function foo( $var ){
>       include $var.'.php';
>       return $var(); // <!------- problem
> };
> 
> foo("somefunction");
> 
> In other words I am looking for a way to call a function by the value of a  
> variable. I get a Call to undefined method error,
> any help would be great..

You are calling the function correctly when using a variable. Namely:

    $var();

Check that the include file you want included is actually being
included. My guess is that it is not, or the function you expect to be
defined in it is not actually defined there.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
Thats great thanks, but it doesn't solve my problem completly, im trying to 
use $output = $var(); .. which gives me an error. The $var(); works though, 
so thanks for that.

Robert Keizer
""Robert Keizer"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I am currently working on a module testing class, I can't seem to find the 
>correct syntax. Here is an example of the problem:
>
> function foo( $var ){
> include $var.'.php';
> return $var(); // <!------- problem
> };
>
> foo("somefunction");
>
> In other words I am looking for a way to call a function by the value of a 
> variable. I get a Call to undefined method error,
> any help would be great..
>
> -- 
> [EMAIL PROTECTED] 

--- End Message ---
--- Begin Message ---
I tested this functionality.

This is working fine.

 

foo.php

<?

function foo( $var ){

      include $var.'.php';

      return $var(); 

};

 

foo("somefunction");

?>

somefunction.php

<?

function somefunction(){

      echo "hello";

}

?>

Out put is hello.

 

You make sure that your both files are in same folder and make sure that
$var.'.php' is exist with $var function.

 

Warm Regards,

Sanjeev

http://www.sanchanworld.com/

http://webdirectory.sanchanworld.com - Submit your website URL

http://webhosting.sanchanworld.com - Choose your best web hosting plan

-----Original Message-----
From: Robert Keizer [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 26, 2007 11:16 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Calling functions which names are inside a variable

 

I am currently working on a module testing class, I can't seem to find the  

correct syntax. Here is an example of the problem:

 

function foo( $var ){

      include $var.'.php';

      return $var(); // <!------- problem

};

 

foo("somefunction");

 

In other words I am looking for a way to call a function by the value of a  

variable. I get a Call to undefined method error,

any help would be great..

 

-- 

[EMAIL PROTECTED]

 

-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
I am trying to find out which string is the longest and then find out what
is different between the two string. Sometimes String 2 is longer than
String 1 The script below works sometimes but not all the time.
Is there a better way to do this or tell me what is wrong with the script I
am using
 
$string1 = "1,2,3,4,5,6,7,8";
$string2 = "1,2,3,4,6,7,8"; 
 
 
 
function compare_by_length ($a, $b)
{
    $la = strlen ($a);
    $lb = strlen ($b);
    if ($la == $lb) return (0);
    return ($a > $b) ? 1 : 2;
}
 
$string1 = "1,2,3,4,5,6,7,8";
$string2 = "1,2,3,4,6,7,8"; 
 
$longstring=compare_by_length ($string1, $string2);
 
if ($longstring=="0"){
  echo "nochange" . $longstring;
  echo"<br>";
}
if ($longstring=="1"){
  echo "List " . $longstring;
  echo"<br>";
  $array1 = explode(",", $string1);
  $array2 = explode(",", $string2);
}
if ($longstring=="2"){
  echo "List " . $longstring;
  echo"<br>";
  $array1 = explode(",", $string2);
  $array2 = explode(",", $string1);
 
}
 
   for ($i = 0; $i < count($array1); $i++) {
      $associative_array[$array1[$i]] = 1;
   }
   
   // print "Not a member of the following lists:<br>\n";
   for ($i = 0; $i < count($array2); $i++) {
      if (!$associative_array[$array2[$i]]) {
         print "$array2[$i]<br>\n";
      }
   }

--- End Message ---
--- Begin Message ---
Okay, why not try somthing like this:

$string1 = "1,2,3,4,5,6,7,8";
$string2 = "2,4,6,8,10";

$ary1 = implode(",",$string1);
$ary2 = implode(",",$string2);

$num1 = '';
$num2 = '';
foreach($ary1 as $num){
    $num1 .= $num;
}
foreach($ary2 as $num){
    $num2 .= $num;
}

that would get the strings into "12345678" and "246810" respectfully, so you 
could do simple add, subtract, greater than, less than, etc... hope this was 
helpful.

Robert Keizer
""Richard Kurth"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I am trying to find out which string is the longest and then find out what
> is different between the two string. Sometimes String 2 is longer than
> String 1 The script below works sometimes but not all the time.
> Is there a better way to do this or tell me what is wrong with the script 
> I
> am using
>
> $string1 = "1,2,3,4,5,6,7,8";
> $string2 = "1,2,3,4,6,7,8";
>
>
>
> function compare_by_length ($a, $b)
> {
>    $la = strlen ($a);
>    $lb = strlen ($b);
>    if ($la == $lb) return (0);
>    return ($a > $b) ? 1 : 2;
> }
>
> $string1 = "1,2,3,4,5,6,7,8";
> $string2 = "1,2,3,4,6,7,8";
>
> $longstring=compare_by_length ($string1, $string2);
>
> if ($longstring=="0"){
>  echo "nochange" . $longstring;
>  echo"<br>";
> }
> if ($longstring=="1"){
>  echo "List " . $longstring;
>  echo"<br>";
>  $array1 = explode(",", $string1);
>  $array2 = explode(",", $string2);
> }
> if ($longstring=="2"){
>  echo "List " . $longstring;
>  echo"<br>";
>  $array1 = explode(",", $string2);
>  $array2 = explode(",", $string1);
>
> }
>
>   for ($i = 0; $i < count($array1); $i++) {
>      $associative_array[$array1[$i]] = 1;
>   }
>
>   // print "Not a member of the following lists:<br>\n";
>   for ($i = 0; $i < count($array2); $i++) {
>      if (!$associative_array[$array2[$i]]) {
>         print "$array2[$i]<br>\n";
>      }
>   }
> 

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

I am trying to get your actual problem.
First, you want to compare 2 strings and want to check what the difference
between these 2 strings is. I assuming string may contain either numbers or
any characters.

Second, you are trying to compare the numbers.

But I am thinking that your problem is first case.
Then first you check the length, and then check character by character
(check each position, if different character at same position means changed)
for each string.

Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan

-----Original Message-----
From: Richard Kurth [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 26, 2007 11:41 AM
To: [EMAIL PROTECTED]
Subject: [PHP] determine which string is longer and then what is different
in that string

I am trying to find out which string is the longest and then find out what
is different between the two string. Sometimes String 2 is longer than
String 1 The script below works sometimes but not all the time.
Is there a better way to do this or tell me what is wrong with the script I
am using
 
$string1 = "1,2,3,4,5,6,7,8";
$string2 = "1,2,3,4,6,7,8"; 
 
 
 
function compare_by_length ($a, $b)
{
    $la = strlen ($a);
    $lb = strlen ($b);
    if ($la == $lb) return (0);
    return ($a > $b) ? 1 : 2;
}
 
$string1 = "1,2,3,4,5,6,7,8";
$string2 = "1,2,3,4,6,7,8"; 
 
$longstring=compare_by_length ($string1, $string2);
 
if ($longstring=="0"){
  echo "nochange" . $longstring;
  echo"<br>";
}
if ($longstring=="1"){
  echo "List " . $longstring;
  echo"<br>";
  $array1 = explode(",", $string1);
  $array2 = explode(",", $string2);
}
if ($longstring=="2"){
  echo "List " . $longstring;
  echo"<br>";
  $array1 = explode(",", $string2);
  $array2 = explode(",", $string1);
 
}
 
   for ($i = 0; $i < count($array1); $i++) {
      $associative_array[$array1[$i]] = 1;
   }
   
   // print "Not a member of the following lists:<br>\n";
   for ($i = 0; $i < count($array2); $i++) {
      if (!$associative_array[$array2[$i]]) {
         print "$array2[$i]<br>\n";
      }
   }

--- End Message ---
--- Begin Message ---
Dear Sanjeev,

you're right. I am sorry for my carelessness. I corrected my code and than try 
it again. But again, it does not work as I expect.

I even put << prompt("this function is being called"); >> in the jsopsi() but 
again the prompt does not come out. Pffuih... I am desperate only because of 
this small thing.

Please keep telling me what's wrong with my code. Do I have to write the 
JavaScript in another way if the javascript is placed in php file?
==
//This is my current code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
  <META name="generator" content="HTML Tidy for Linux/x86 (vers 31 October 
2006), see www.w3.org">

  <TITLE>guru.com - Menu for new customer</TITLE>

<Script Language="JavaScript">
function jsopsi(){
prompt("This prompt comes out if this function is really being called");
if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){
        document.formulir.opsistate.options[5].selected=true;
}
}
</Script>
</head>
<BODY>
<?php
if (isset($pid)){
        $idproduk=$_GET['pid'];
        echo "Produk ID: $idproduk<br>";
}
?>

<table border=0 align="center" cellpadding=0 cellspacing=0 width=800>
<tr><td></td><td><table border=0 align="center" cellpadding=0 cellspacing=0 
width=400>
<form method="post" action="cgi/cgipelangganbaru.php?pid=$idproduk" 
name="formulir">
<tr>
        <td align="right" bgcolor="#F5D78B">
        3. Country:
        </td>
        <td align="center">
        </td>
        <td align="left">
        <select name="negara" onchange="jsopsi()" name="opsinegara">
        <?php
        include_once "koneksi.php";
        $sqlnya="select country from countries";
        $kelas=new koneksi();
        $klas=$kelas->getkoneksi("survey",$sqlnya);
        if ( mysql_num_rows($klas) > 0 ) {
        while( list($negara) = mysql_fetch_row($klas) ) {
                echo "<option id=\"opsi"."$negara\" 
value=\"$negara\">$negara</option>";
        }
        } else {
                echo 'No results found';
        }
        ?>
        </select>
        </td>
</tr>
<tr>
        <td align="right" bgcolor="#F5D78B">
        4. State:
        </td>
        <td align="center">
        </td>
        <td align="left">
        <select name="opsistate">
        <?php
        include_once "koneksi.php";
        $sqlnya="select state,statename from states";
        $kelas=new koneksi();
        $klas=$kelas->getkoneksi("survey",$sqlnya);
        if ( mysql_num_rows($klas) > 0 ) {
        echo "<option name=\"state\" value=\"\"></option>";
        while( list($state,$statename) = mysql_fetch_row($klas) ) {
                echo "<option name=\"state\" value=\"$state\">$statename 
($state)</option>";
        }
        } else {
                echo 'No results found';
        }
        ?>
        </select>
        </td>
</tr>
</form>
</table>
</td><td></td></tr></table>
</BODY>
</HTML>
==
On Sat, 25 Aug 2007 22:26:49 +0530
"Sanjeev N" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> JavaScript codes works in php files. Yours code is also fine. 
> But check your calling function and defined functions. Calling function is
> jsopsi and defined function is opsi. Please check. Other than this
> everything is ok
> 
> Warm Regards,
> Sanjeev
> http://www.sanchanworld.com/
> http://webdirectory.sanchanworld.com - Submit your website URL
> http://webhosting.sanchanworld.com - Choose your best web hosting plan
> -----Original Message-----
> From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, August 25, 2007 9:17 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Does JavaScript not work in php web file?
> 
> Dear my friends...
> 
> I am confused to implement JavaScript code in php web file.
> 
> I want my JavaScript change the "selected" item of <select> tag based on the
> "selected" item of previous <selected> in same php page.
> 
> Please help me.... tell my where is my mistake.
> 
> ===
> Here is my code pelangganbaru.php
> ===
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> 
> <HTML>
> <HEAD>
>   <META name="generator" content="HTML Tidy for Linux/x86 (vers 31 October
> 2006), see www.w3.org">
> 
>   <TITLE>guru.com - Menu for new customer</TITLE>
> </HEAD>
> <Script Language="JavaScript">
> function opsi(){
> if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){
>       document.formulir.opsistate.options[0].selected=true;
> }
> }
> </Script>
> 
> <BODY>
> <?php
> if (isset($pid)){
>       $idproduk=$_GET['pid'];
>       echo "Produk ID: $idproduk<br>";
> }
> ?>
> 
> <table border=0 align="center" cellpadding=0 cellspacing=0 width=800>
> <tr><td></td><td><table border=0 align="center" cellpadding=0 cellspacing=0
> width=400>
> <form method="post" action="cgi/cgipelangganbaru.php?pid=$idproduk"
> name="formulir">
> <tr>
>       <td align="right" bgcolor="#F5D78B">
>       3. Country:
>       </td>
>       <td align="center">
>       </td>
>       <td align="left">
>       <select name="negara" onchange="jsopsi()" name="opsinegara">
>       <?php
>       include_once "koneksi.php";
>       $sqlnya="select country from countries";
>       $kelas=new koneksi();
>       $klas=$kelas->getkoneksi("survey",$sqlnya);
>       if ( mysql_num_rows($klas) > 0 ) {
>       while( list($negara) = mysql_fetch_row($klas) ) {
>               echo "<option id=\"opsi"."$negara\"
> value=\"$negara\">$negara</option>";
>       }
>       } else {
>               echo 'No results found';
>       }
>       ?>
>       </select>
>       </td>
> </tr>
> <tr>
>       <td align="right" bgcolor="#F5D78B">
>       4. State:
>       </td>
>       <td align="center">
>       </td>
>       <td align="left">
>       <select name="opsistate">
>       <?php
>       include_once "koneksi.php";
>       $sqlnya="select state,statename from states";
>       $kelas=new koneksi();
>       $klas=$kelas->getkoneksi("survey",$sqlnya);
>       if ( mysql_num_rows($klas) > 0 ) {
>       echo "<option name=\"opsi".$state."\" value=\"\"></option>";
>       if ($negara=="Virgin Islands (US)"){
>               echo "<option name=\"nonusa\" value=\"00\" selected>Non
> USA</option>";
>       }else{
>               echo "<option name=\"nonusa\" value=\"00\">Non
> USA</option>";
>       }
>       while( list($state,$statename) = mysql_fetch_row($klas) ) {
>               echo "<option name=\"state\" value=\"$state\">$statename
> ($state)</option>";
>       }
>       } else {
>               echo 'No results found';
>       }
>       ?>
>       </select>
>       </td>
> </tr>
> <tr>
>       <td align="right">
>       <input type="submit">
>       </td>
>       <td align="center">
>       </td>
>       <td align="left">
>       <input type="reset">
>       </td>
> </tr>
> </form>
> </table>
> </td><td></td></tr></table>
> </BODY>
> </HTML>
> -- 
> Patrik Hasibuan <[EMAIL PROTECTED]>
> Junior Programmer
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 


-- 
Patrik Hasibuan <[EMAIL PROTECTED]>
Junior Programmer

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

 

I tried this code by removing PHP codes and made as HTML. As you said prompt
dint come to me also. When I checked JavaScript errors then I saw that
prompt function had some errors (like ; in wrong place). I have corrected
the errors in script.

 

<Script Language="JavaScript">

function jsopsi(){

prompt("This prompt comes out if this function is really being called"); 

if(document.formulir.opsinegara.value!="Virgina Islands (USA)"){

      document.formulir.opsistate.options[5].selected=true;

}

}

</Script>

 

And the complete code after converting to HTML is as follows.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<HTML>

<HEAD>

  <META name="generator" content="HTML Tidy for Linux/x86 (vers 31 October
2006), see www.w3.org">

 

  <TITLE>guru.com - Menu for new customer</TITLE>

 

<Script Language="JavaScript">

function jsopsi(){

prompt("This prompt comes out if this function is really being called"); 

if(document.formulir.opsinegara.value!="Virgina Islands (USA)"){

      document.formulir.opsistate.options[5].selected=true;

}

}

</Script>

</head>

<BODY>

<?php

if (isset($pid)){

      $idproduk=$_GET['pid'];

      echo "Produk ID: $idproduk<br>";

}

?>

 

<table border=0 align="center" cellpadding=0 cellspacing=0 width=800>
<tr><td></td><td><table border=0 align="center" cellpadding=0 cellspacing=0
width=400> <form method="post"
action="cgi/cgipelangganbaru.php?pid=$idproduk" name="formulir"> <tr>

      <td align="right" bgcolor="#F5D78B">

      3. Country:

      </td>

      <td align="center">

      </td>

      <td align="left">

      <select name="negara" onchange="jsopsi()" name="opsinegara">

            <option id="opsi1" value="negara1">negara1</option>

            <option id="opsi2" value="negara2">negara2</option>

            <option id="opsi3" value="negara3">negara3</option>

            <option id="opsi4" value="negara4">negara4</option>

            <option id="opsi5" value="negara5">negara5</option>

      </select>

      </td>

</tr>

<tr>

      <td align="right" bgcolor="#F5D78B">

      4. State:

      </td>

      <td align="center">

      </td>

      <td align="left">

      <select name="opsistate">     

      <option name="state1" value="1">1</option>

      <option name="state2" value="2">4</option>

      <option name="state3" value="3">3</option>

      </select>

      </td>

</tr>

</form>

</table>

</td><td></td></tr></table>

</BODY>

</HTML>

 

You please check with PHP codes included (also I suggest you check the
javascript errors if it don't works). 

 

Warm Regards,

Sanjeev

http://www.sanchanworld.com/

http://webdirectory.sanchanworld.com - Submit your website URL

http://webhosting.sanchanworld.com - Choose your best web hosting plan

-----Original Message-----
From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 26, 2007 3:12 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Does JavaScript not work in php web file?

 

Dear Sanjeev,

 

you're right. I am sorry for my carelessness. I corrected my code and than
try it again. But again, it does not work as I expect.

 

I even put << prompt("this function is being called"); >> in the jsopsi()
but again the prompt does not come out. Pffuih... I am desperate only
because of this small thing.

 

Please keep telling me what's wrong with my code. Do I have to write the
JavaScript in another way if the javascript is placed in php file?

==

//This is my current code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<HTML>

<HEAD>

  <META name="generator" content="HTML Tidy for Linux/x86 (vers 31 October
2006), see www.w3.org">

 

  <TITLE>guru.com - Menu for new customer</TITLE>

 

<Script Language="JavaScript">

function jsopsi(){

prompt("This prompt comes out if this function is really being called");

if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){

      document.formulir.opsistate.options[5].selected=true;

}

}

</Script>

</head>

<BODY>

<?php

if (isset($pid)){

      $idproduk=$_GET['pid'];

      echo "Produk ID: $idproduk<br>";

}

?>

 

<table border=0 align="center" cellpadding=0 cellspacing=0 width=800>

<tr><td></td><td><table border=0 align="center" cellpadding=0 cellspacing=0
width=400>

<form method="post" action="cgi/cgipelangganbaru.php?pid=$idproduk"
name="formulir">

<tr>

      <td align="right" bgcolor="#F5D78B">

      3. Country:

      </td>

      <td align="center">

      </td>

      <td align="left">

      <select name="negara" onchange="jsopsi()" name="opsinegara">

      <?php

      include_once "koneksi.php";

      $sqlnya="select country from countries";

      $kelas=new koneksi();

      $klas=$kelas->getkoneksi("survey",$sqlnya);

      if ( mysql_num_rows($klas) > 0 ) {

      while( list($negara) = mysql_fetch_row($klas) ) {

            echo "<option id=\"opsi"."$negara\"
value=\"$negara\">$negara</option>";

      }

      } else {

            echo 'No results found';

      }

      ?>

      </select>

      </td>

</tr>

<tr>

      <td align="right" bgcolor="#F5D78B">

      4. State:

      </td>

      <td align="center">

      </td>

      <td align="left">

      <select name="opsistate">

      <?php

      include_once "koneksi.php";

      $sqlnya="select state,statename from states";

      $kelas=new koneksi();

      $klas=$kelas->getkoneksi("survey",$sqlnya);

      if ( mysql_num_rows($klas) > 0 ) {

      echo "<option name=\"state\" value=\"\"></option>";

      while( list($state,$statename) = mysql_fetch_row($klas) ) {

            echo "<option name=\"state\" value=\"$state\">$statename
($state)</option>";

      }

      } else {

            echo 'No results found';

      }

      ?>

      </select>

      </td>

</tr>

</form>

</table>

</td><td></td></tr></table>

</BODY>

</HTML>

==

On Sat, 25 Aug 2007 22:26:49 +0530

"Sanjeev N" <[EMAIL PROTECTED]> wrote:

 

> Hi,

> 

> JavaScript codes works in php files. Yours code is also fine. 

> But check your calling function and defined functions. Calling function is

> jsopsi and defined function is opsi. Please check. Other than this

> everything is ok

> 

> Warm Regards,

> Sanjeev

> http://www.sanchanworld.com/

> http://webdirectory.sanchanworld.com - Submit your website URL

> http://webhosting.sanchanworld.com - Choose your best web hosting plan

> -----Original Message-----

> From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 

> Sent: Saturday, August 25, 2007 9:17 PM

> To: [EMAIL PROTECTED]

> Subject: [PHP] Does JavaScript not work in php web file?

> 

> Dear my friends...

> 

> I am confused to implement JavaScript code in php web file.

> 

> I want my JavaScript change the "selected" item of <select> tag based on
the

> "selected" item of previous <selected> in same php page.

> 

> Please help me.... tell my where is my mistake.

> 

> ===

> Here is my code pelangganbaru.php

> ===

> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

> 

> <HTML>

> <HEAD>

>   <META name="generator" content="HTML Tidy for Linux/x86 (vers 31 October

> 2006), see www.w3.org">

> 

>   <TITLE>guru.com - Menu for new customer</TITLE>

> </HEAD>

> <Script Language="JavaScript">

> function opsi(){

> if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){

>     document.formulir.opsistate.options[0].selected=true;

> }

> }

> </Script>

> 

> <BODY>

> <?php

> if (isset($pid)){

>     $idproduk=$_GET['pid'];

>     echo "Produk ID: $idproduk<br>";

> }

> ?>

> 

> <table border=0 align="center" cellpadding=0 cellspacing=0 width=800>

> <tr><td></td><td><table border=0 align="center" cellpadding=0
cellspacing=0

> width=400>

> <form method="post" action="cgi/cgipelangganbaru.php?pid=$idproduk"

> name="formulir">

> <tr>

>     <td align="right" bgcolor="#F5D78B">

>     3. Country:

>     </td>

>     <td align="center">

>     </td>

>     <td align="left">

>     <select name="negara" onchange="jsopsi()" name="opsinegara">

>     <?php

>     include_once "koneksi.php";

>     $sqlnya="select country from countries";

>     $kelas=new koneksi();

>     $klas=$kelas->getkoneksi("survey",$sqlnya);

>     if ( mysql_num_rows($klas) > 0 ) {

>     while( list($negara) = mysql_fetch_row($klas) ) {

>           echo "<option id=\"opsi"."$negara\"

> value=\"$negara\">$negara</option>";

>     }

>     } else {

>           echo 'No results found';

>     }

>     ?>

>     </select>

>     </td>

> </tr>

> <tr>

>     <td align="right" bgcolor="#F5D78B">

>     4. State:

>     </td>

>     <td align="center">

>     </td>

>     <td align="left">

>     <select name="opsistate">

>     <?php

>     include_once "koneksi.php";

>     $sqlnya="select state,statename from states";

>     $kelas=new koneksi();

>     $klas=$kelas->getkoneksi("survey",$sqlnya);

>     if ( mysql_num_rows($klas) > 0 ) {

>     echo "<option name=\"opsi".$state."\" value=\"\"></option>";

>     if ($negara=="Virgin Islands (US)"){

>           echo "<option name=\"nonusa\" value=\"00\" selected>Non

> USA</option>";

>     }else{

>           echo "<option name=\"nonusa\" value=\"00\">Non

> USA</option>";

>     }

>     while( list($state,$statename) = mysql_fetch_row($klas) ) {

>           echo "<option name=\"state\" value=\"$state\">$statename

> ($state)</option>";

>     }

>     } else {

>           echo 'No results found';

>     }

>     ?>

>     </select>

>     </td>

> </tr>

> <tr>

>     <td align="right">

>     <input type="submit">

>     </td>

>     <td align="center">

>     </td>

>     <td align="left">

>     <input type="reset">

>     </td>

> </tr>

> </form>

> </table>

> </td><td></td></tr></table>

> </BODY>

> </HTML>

> -- 

> Patrik Hasibuan <[EMAIL PROTECTED]>

> Junior Programmer

> 

> -- 

> PHP General Mailing List (http://www.php.net/)

> To unsubscribe, visit: http://www.php.net/unsub.php

> 

> 

> 

 

 

-- 

Patrik Hasibuan <[EMAIL PROTECTED]>

Junior Programmer

 

-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Hi, this is my first post to this newsgroup. Does this code look ok or is there 
a more clean way of doing this? I am learning. Thank you for reading.
Jason

   if ( !empty($_REQUEST['gender']) )
          {
            $registrationGender=$_REQUEST['gender'];
          }
          else {
                 if (session_is_registered('registrationGender'))
                  {
                   $registrationGender=$_SESSION['registrationGender'];
                   print "you are preregistered as a $registrationGender";
                  }
                  else
                  {
                   print "your gender is unknown, youare assumed to be a male";
                   $registrationGender="male";
                  }
               }

        $_SESSION['registrationGender']=$registrationGender;

_________________________________________________________________
100’s of Music vouchers to be won with MSN Music
https://www.musicmashup.co.uk/index.html

--- End Message ---
--- Begin Message ---
On 8/26/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:

I would replace $_REQUEST with $_GET or $_POST (as appropriate)

>   if ( !empty($_REQUEST['gender']) )
>          {
>            $registrationGender=$_REQUEST['gender'];
>          }
>          else {

Personally I would use if(isset($_SESSION['registrationGender'])) here

>                 if (session_is_registered('registrationGender'))
>                  {
>                   $registrationGender=$_SESSION['registrationGender'];
>                   print "you are preregistered as a $registrationGender";
>                  }
>                  else
>                  {
>                   print "your gender is unknown, youare assumed to be a male";

        $_SESSION['registrationGender']='male';

I would change it to assign it here. No need to assign it a second
time below, since you are just printing the session variable if it is
already set

>                  }
>               }
>

Those are a couple quick things my tired bloodshot eyes thought of.

--- End Message ---
--- Begin Message ---
I would go for:

    if (isset($_REQUEST['gender'])) $_SESSION['registrationGender'] =
$_REQUEST['gender'];
    print isset($_SESSION['registrationGender']) ? "You are registered as
gender: ".$_SESSION['registrationGender'] : "Your gender is unknown";

And make no assumptions about a gender when you don't know any ;-)

On 26/08/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:
>
>
> Hi, this is my first post to this newsgroup. Does this code look ok or is
> there a more clean way of doing this? I am learning. Thank you for reading.
> Jason
>
>    if ( !empty($_REQUEST['gender']) )
>           {
>             $registrationGender=$_REQUEST['gender'];
>           }
>           else {
>                  if (session_is_registered('registrationGender'))
>                   {
>                    $registrationGender=$_SESSION['registrationGender'];
>                    print "you are preregistered as a $registrationGender";
>                   }
>                   else
>                   {
>                    print "your gender is unknown, youare assumed to be a
> male";
>                    $registrationGender="male";
>                   }
>                }
>
>         $_SESSION['registrationGender']=$registrationGender;
>
> _________________________________________________________________
> 100's of Music vouchers to be won with MSN Music
> https://www.musicmashup.co.uk/index.html
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Interpotential.com
Phone: +31615397471

--- End Message ---
--- Begin Message ---
Is there a PHP command that turns text into HTML?

EXAMPLE:

"before"

Hi.

How are you doing?

"after"

Hi.<p>

How are you doing?<p>


--- End Message ---
--- Begin Message ---
the closest is nl2br() which converts line breaks to  tags. Other than that, 
you would need to look at regex manipulation to make those changes.

Bastien




----------------------------------------
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Date: Sun, 26 Aug 2007 10:36:06 -0400
> Subject: [PHP] text to HTML
> 
> 
> Is there a PHP command that turns text into HTML?
> 
> EXAMPLE:
> 
> "before"
> 
> Hi.
> 
> How are you doing?
> 
> "after"
> 
> Hi.
> 
> How are you doing?
> 

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

--- End Message ---
--- Begin Message ---
Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.
I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.
I do not know where else to look for an answer to this question
at present.
Any knowledgeable response appreciated.
Thanks in advance:
Jeff K.

--- End Message ---
--- Begin Message ---
jekillen wrote:
Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.

No, the best solution is for your application to grab the path to that particular user's directory and assign a unique name to the uploaded file, then move it from the temp dir:

move_uploaded_file($_FILES['upload_file']['tmp_name'], $upload_path);

where 'upload_file' is the name of your upload form field.

http://www.php.net/manual/en/function.move-uploaded-file.php

I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.

That's unlikely to occur. In fact, i'd be surprised if it were possible that PHP would assign a temp name that already existed.

brian

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

that's not a problem to specify where the uploaded file has to be moved after upload. As you specify for each user a personal directory in the system, you just need to use a function like move_uploaded_file() to move the uploaded file to this directory. Each uploaded file goes to, let's say, /tmp (the directory specified in your php config), and inherits from a unique filename. This filename is contained in the $_FILES array available in the script which handles the upload. So if you have a form containing a file upload field called "file", you can retrieve the filename of the newly uploaded file using: $_FILES['file']['tmp_name'] (if the upload went successfully).
You can then simply use:
move_uploaded_file( $_FILES['file']['tmp_name'], '/path/to/user/personal/dir');

This will work even if multiple users are uploading a file at the same time, as the $_FILES array will contain the info related to a single user.

I hope I've been clear enough...

Ludo
Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.
I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.
I do not know where else to look for an answer to this question
at present.
Any knowledgeable response appreciated.
Thanks in advance:
Jeff K.


--- End Message ---
--- Begin Message --- Im trying to delete a composite key but cannot figure out the proper format. Would somebody tell me where im messing up? I have an url that is supposed to send the member id and game id to a delete query. And the delete query is supposed to grab the id's based on type.



This is the link:

<a href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME REMOVAL]</a></td>\n";



This is the code that recieves the link information:

case "remove":
     switch ($_GET['type']) {
       case "Member":
 if (!isset($_GET['do']) || $_GET['do'] != 1) {
?>
 <p align="center" style="color:#FF0000">
   Are you sure you want to delete this <?php
   echo $_GET['type']; ?>?<br>
   <a href="<?php echo $_SERVER['REQUEST_URI']; ?>&do=1">yes</a>
   or <a href="member_view.php">Index</a>
 </p>
<?php
 } else {
   if ($_GET['type'] == "Member") {
     // delete reference to member
   $sql = "DELETE
          FROM xsm_membergames
WHERE Member_id = '" . mysql_real_escape_string((int)$_GET['id']) . " .
    AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) . "'";
   }
 }

_________________________________________________________________
Messenger Café — open for fun 24/7. Hot games, cool activities served daily. Visit now. http://cafemessenger.com?ocid=TXT_TAGHM_AugHMtagline
--- End Message ---

Reply via email to