[PHP] Class not returning value

2009-11-25 Thread Pieter du Toit
Hi

This is my first class and it does not work, i do a return 
$this-responseArray; with the public function getResult() method, but get 
nothing. Can someone please help me.

Thsi is how i create the object
$number = new Smsgate($cell_numbers, $message, 27823361602, 27);
$result = $number-getResult();

Here is the code:
?php

/**
 *
 * @version 1.0
 * @copyright 2009
 */

/**
 */
class Smsgate {

protected $number;
protected $message;
protected $sender_id;
protected $tofind;
private $result;
/**
 * Constructor
 */
function __construct($number = , $message = , $sender_id = , 
$tofind = )
{

$this-message = $message;
$this-number = $number;
$this-sender_id = $sender_id;
$this-tofind = $tofind;
}

protected function display ($result)
{
return $result;
}

public function getResult()
{
return $this-processRequest();

}
public function numberErrors()
{
return $this-errorResult;
}

/**
 * Smsgate::checknumbers()
 *
 * @return array of correct and incorrect formatted numbers
 */
private function processRequest()
{
echo nou by numers;
print_r($this-number);
// check if the property is an array and add to new array for 
sending
if (is_array($this-number)) {
// check for starting digits
$this-result = ;
// loop through numbers and check for errors
foreach ($this-number as $this-val) {

$this-position = strpos($this-val , $this-tofind);

// number correct
if ($this-position === 0) {
echo is integer br/;
if ($this-result != ) {
$this-result .= ,;
}
// create comma seperated numbers to send as bulk in 
sendSMS method
$this-result .= $this-val; //infobip multiple 
recipients must be seperated by comma
// create an array to use with responseStringExplode in 
sendSMS method
$this-cellarray[] = $this-val;
echo Result is  . $this-result . br;
} else {
// numbers not in correct format
$this-errorResult[] = $this-val;
}

} //end foreach
   $this-sendSMS();

} else {
$this-result = Not ok;
 return $this-result;
}

}

private function sendSMS()
{

$this-smsUrl = 
'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=password=';
$this-post_data = 'sender=' . $this-sender_id . 'SMSText=' . 
urlencode($this-message) . 'IsFlash=0GSM=' . $this-result;
$this-sendData = $this-sendWithCurl($this-smsUrl, 
$this-post_data);
$this-responseStringExplode = explode(\n, $this-sendData);

 $count=0;
foreach ($this-responseStringExplode as $this-rvalue) {
  $this-responseArray[$this-rvalue] = ($this-cellarray[$count]);
  $count = ++$count;
}
 return $this-responseArray;
}
 private function sendWithCurl($url, $postData) {
  if (!is_resource($this-connection_handle)) {
   // Try to create one
   if (!$this-connection_handle = curl_init()) {
trigger_error('Could not start new CURL instance');
$this-error = true;
return;
   }
  }
  curl_setopt($this-connection_handle, CURLOPT_URL, $url);
  curl_setopt ($this-connection_handle, CURLOPT_POST, 1);
  $post_fields = $postData;
  curl_setopt ($this-connection_handle, CURLOPT_POSTFIELDS, $post_fields);
  curl_setopt($this-connection_handle, CURLOPT_RETURNTRANSFER, 1);
  $this-response_string = curl_exec($this-connection_handle);
  curl_close($this-connection_handle);
  return $this-response_string;
 }
}

? 



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



[PHP] Re: Class not returning value

2009-11-25 Thread Pieter du Toit
Sorry i found the problem, need to do this:
public function getResult()
{
$this-processRequest();
 return $this-responseArray;

}

Pieter du Toit pie...@lpwebdesign.co.za wrote in message 
news:57.90.5.88fec...@pb1.pair.com...
 Hi

 This is my first class and it does not work, i do a return 
 $this-responseArray; with the public function getResult() method, but get 
 nothing. Can someone please help me.

 Thsi is how i create the object
 $number = new Smsgate($cell_numbers, $message, 27823361602, 27);
 $result = $number-getResult();

 Here is the code:
 ?php

 /**
 *
 * @version 1.0
 * @copyright 2009
 */

 /**
 */
 class Smsgate {

protected $number;
protected $message;
protected $sender_id;
protected $tofind;
private $result;
/**
 * Constructor
 */
function __construct($number = , $message = , $sender_id = , 
 $tofind = )
{

$this-message = $message;
$this-number = $number;
$this-sender_id = $sender_id;
$this-tofind = $tofind;
}

protected function display ($result)
{
return $result;
}

public function getResult()
{
return $this-processRequest();

}
public function numberErrors()
{
return $this-errorResult;
}

/**
 * Smsgate::checknumbers()
 *
 * @return array of correct and incorrect formatted numbers
 */
private function processRequest()
{
echo nou by numers;
print_r($this-number);
// check if the property is an array and add to new array for 
 sending
if (is_array($this-number)) {
// check for starting digits
$this-result = ;
// loop through numbers and check for errors
foreach ($this-number as $this-val) {

$this-position = strpos($this-val , $this-tofind);

// number correct
if ($this-position === 0) {
echo is integer br/;
if ($this-result != ) {
$this-result .= ,;
}
// create comma seperated numbers to send as bulk in 
 sendSMS method
$this-result .= $this-val; //infobip multiple 
 recipients must be seperated by comma
// create an array to use with responseStringExplode in 
 sendSMS method
$this-cellarray[] = $this-val;
echo Result is  . $this-result . br;
} else {
// numbers not in correct format
$this-errorResult[] = $this-val;
}

} //end foreach
   $this-sendSMS();

} else {
$this-result = Not ok;
 return $this-result;
}

}

private function sendSMS()
{

$this-smsUrl = 
 'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=password=';
$this-post_data = 'sender=' . $this-sender_id . 'SMSText=' . 
 urlencode($this-message) . 'IsFlash=0GSM=' . $this-result;
$this-sendData = $this-sendWithCurl($this-smsUrl, 
 $this-post_data);
$this-responseStringExplode = explode(\n, $this-sendData);

 $count=0;
foreach ($this-responseStringExplode as $this-rvalue) {
  $this-responseArray[$this-rvalue] = ($this-cellarray[$count]);
  $count = ++$count;
}
 return $this-responseArray;
}
 private function sendWithCurl($url, $postData) {
  if (!is_resource($this-connection_handle)) {
   // Try to create one
   if (!$this-connection_handle = curl_init()) {
trigger_error('Could not start new CURL instance');
$this-error = true;
return;
   }
  }
  curl_setopt($this-connection_handle, CURLOPT_URL, $url);
  curl_setopt ($this-connection_handle, CURLOPT_POST, 1);
  $post_fields = $postData;
  curl_setopt ($this-connection_handle, CURLOPT_POSTFIELDS, $post_fields);
  curl_setopt($this-connection_handle, CURLOPT_RETURNTRANSFER, 1);
  $this-response_string = curl_exec($this-connection_handle);
  curl_close($this-connection_handle);
  return $this-response_string;
 }
 }

 ?
 



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



[PHP] Re: Class not returning value

2009-11-25 Thread Pieter du Toit
Thanks for th reply Peter

i call this method on success
$this-sendSMS();

But i sorted the problem with this:
 public function getResult()
{
$this-processRequest();
 return $this-responseArray;

}

Peter Ford p...@justcroft.com wrote in message 
news:cf.a1.5.d5cfc...@pb1.pair.com...
 Pieter du Toit wrote:
 Hi

 This is my first class and it does not work, i do a return
 $this-responseArray; with the public function getResult() method, but 
 get
 nothing. Can someone please help me.

 Thsi is how i create the object
 $number = new Smsgate($cell_numbers, $message, 27823361602, 27);
 $result = $number-getResult();

 Here is the code:
 ?php

 /**
  *
  * @version 1.0
  * @copyright 2009
  */

 /**
  */
 class Smsgate {

 protected $number;
 protected $message;
 protected $sender_id;
 protected $tofind;
 private $result;
 /**
  * Constructor
  */
 function __construct($number = , $message = , $sender_id = ,
 $tofind = )
 {

 $this-message = $message;
 $this-number = $number;
 $this-sender_id = $sender_id;
 $this-tofind = $tofind;
 }

 protected function display ($result)
 {
 return $result;
 }

 public function getResult()
 {
 return $this-processRequest();

 }
 public function numberErrors()
 {
 return $this-errorResult;
 }

 /**
  * Smsgate::checknumbers()
  *
  * @return array of correct and incorrect formatted numbers
  */
 private function processRequest()
 {
 echo nou by numers;
 print_r($this-number);
 // check if the property is an array and add to new array for
 sending
 if (is_array($this-number)) {
 // check for starting digits
 $this-result = ;
 // loop through numbers and check for errors
 foreach ($this-number as $this-val) {

 $this-position = strpos($this-val , $this-tofind);

 // number correct
 if ($this-position === 0) {
 echo is integer br/;
 if ($this-result != ) {
 $this-result .= ,;
 }
 // create comma seperated numbers to send as bulk in
 sendSMS method
 $this-result .= $this-val; //infobip multiple
 recipients must be seperated by comma
 // create an array to use with responseStringExplode 
 in
 sendSMS method
 $this-cellarray[] = $this-val;
 echo Result is  . $this-result . br;
 } else {
 // numbers not in correct format
 $this-errorResult[] = $this-val;
 }

 } //end foreach
$this-sendSMS();

 } else {
 $this-result = Not ok;
  return $this-result;
 }

 }

 private function sendSMS()
 {

 $this-smsUrl =
 'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=password=';
 $this-post_data = 'sender=' . $this-sender_id . 'SMSText=' .
 urlencode($this-message) . 'IsFlash=0GSM=' . $this-result;
 $this-sendData = $this-sendWithCurl($this-smsUrl,
 $this-post_data);
 $this-responseStringExplode = explode(\n, $this-sendData);

  $count=0;
 foreach ($this-responseStringExplode as $this-rvalue) {
   $this-responseArray[$this-rvalue] = 
 ($this-cellarray[$count]);
   $count = ++$count;
 }
  return $this-responseArray;
 }
  private function sendWithCurl($url, $postData) {
   if (!is_resource($this-connection_handle)) {
// Try to create one
if (!$this-connection_handle = curl_init()) {
 trigger_error('Could not start new CURL instance');
 $this-error = true;
 return;
}
   }
   curl_setopt($this-connection_handle, CURLOPT_URL, $url);
   curl_setopt ($this-connection_handle, CURLOPT_POST, 1);
   $post_fields = $postData;
   curl_setopt ($this-connection_handle, CURLOPT_POSTFIELDS, 
 $post_fields);
   curl_setopt($this-connection_handle, CURLOPT_RETURNTRANSFER, 1);
   $this-response_string = curl_exec($this-connection_handle);
   curl_close($this-connection_handle);
   return $this-response_string;
  }
 }

 ?




 Based on a first scan of your code, it looks like the only return in
 processRequest() is inside the else block, so nothing is returned unless 
 the
 processing fails.

 -- 
 Peter Ford  phone: 01580 89
 Developer   fax:   01580 893399
 Justcroft International Ltd., Staplehurst, Kent 



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



Re: [PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
I ran it, and here is the output

Array ( [txtPhoto] = Array ( [name] = g1.jpg [type] = image/pjpeg 
[tmp_name] = /tmp/php3qkA4A [error] = 0 [size] = 17008 ) )

Angelo Zanetti [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Have you tried print_r($_FILES); to see all the values in the variable?

 Its difficult to see whats going on as you posted your whole file.



 -Original Message-
 From: Pieter du Toit [mailto:[EMAIL PROTECTED]
 Sent: 05 March 2008 12:38
 To: php-general@lists.php.net
 Subject: [PHP] Re: Variable post as array

 Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it 
 tells
 me that temp_name is also an array, but when i echo
 $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
 vardump i can see that temp name is [tmp_name]= string(14)
 /tmp/phplR1WSl and not an array by itself.

 Im going crazy here

 Pieter du Toit [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi

 I have this weird problem, when i select a file to upload, the variable
 arrives as an array at the action php file, this is the code, and the
 variable name is txtPhoto

 ? include (userpass.inc); ?

 html

 link rel=STYLESHEET type=TEXT/CSS href=specials.css

 titleSpecials Update/title

 /head

 ? include (body_begin.inc); ?

 ?

 echo form ENCTYPE=\multipart/form-data\ method=\POST\ name=\Edit
 Special\ action=\specials_proc.php\\n;

 echo input type=\hidden\ name=\keyClient_Id\
 value=\$g_client_id\;

 echo input type=\hidden\ name=\keySpecial\ value=\$special\;

 echo input type=\hidden\ name=\k_subsystem_id\
 value=\$k_subsystem_id\;

 echo table align=\center\ class=\EditView\ border=\0\
 cellspacing=\0\ cellpadding=\0\ width=\80%\\n;



 if ($special != )

 {

 $new = 0;

 echo tr class=\MainHeader\th colspan=\2\Edit
 Special/th/tr\n;

 $result = mysql(zululandcoza, select * from client_specials where
 client_id = $g_client_id and special = $special);

 if (list($client_id, $special, $description, $special_type, $price,
 $discount, $startdate, $enddate) = mysql_fetch_row($result))

 {

 }

 }

 else

 {

 $new = 1;

 echo tr class=\Header\th colspan=\2\h1New Special (this page 
 is

 undergoing maintenance, please try again later)/h1/th/tr\n;

 $result = mysql(zululandcoza, select max(special) from client_specials
 where client_id = $client_id);

 if (list($max_special) = mysql_fetch_row($result))

 {

 $special = $max_special + 1;

 }

 }



 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Specialnbsp;Number/td\n;

 if ($new)

 echo  td align=\left\ class=\Number\input type=\text\
 name=\txtSpecial\ maxlength=\5\ size=\5\
 value=\$special\/input/td\n;

 else

 echo  td align=\left\ class=\Number\input type=\text\
 name=\txtSpecial\ maxlength=\5\ size=\5\ value=\$special\
 enabled=\0\/input/td\n;

 echo /tr\n;

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Description/td\n;

 echo  td align=\left\ class=\Text\input type=\text\
 name=\txtDescription\ maxlength=\200\ size=\50\
 value=\$description\/input/td\n;

 echo /tr\n;

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Specialnbsp;Type/td\n;

 echo  td align=\left\ class=\Selection\\n;

 $optPRICE = ;

 $optDISC = ;

 $optFROM = ;

 if ($special_type == FROM)

 $optFROM =  SELECTED;

 elseif ($special_type == DISC)

 $optDISC =  SELECTED;

 else

 $optPRICE =  SELECTED;

 echo  select name=\cbxSpecial_Type\\n;

 echo  option value=\PRICE\$optPRICESpecial Price/option\n;

 echo  option value=\DISC\$optDISCDiscount %/option\n;

 echo  option value=\FROM\$optFROMFrom/option\n;

 echo  /select\n;

 echo  /td\n;

 echo /tr\n;

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Price/td\n;

 echo  td align=\left\ class=\Currency\input type=\text\
 name=\txtPrice\ maxlength=\20\ size=\10\
 value=\$price\/input/td\n;

 echo /tr\n;

 if ($k_subsystem_id == 2)

 {

 if (! $new)

 {

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Current Photo/td\n;

 echo  td align=\left\ class=\Currency\img

 src=\showpic.php?keySystem_Id=2keyClient_Id=$g_client_idkeySpecial=$speci
 al\/td\n;

 echo /tr\n;

 }

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\New Photo/td\n;

 echo  td align=\left\ class=\Currency\input type=\file\
 name=\txtPhoto\ size=\50\/input/td\n;

 echo /tr\n;

 }

 echo tr class=\Footer\\n;

 echo  td colspan=\2\\n;

 if ($new)

 {

 echo  input type=\submit\ name=\cmdAdd\ value=\Add\nbsp;\n;

 }

 else

 {

 echo  input type=\submit\ name=\cmdUpdate\
 value=\Update\nbsp;\n;

 echo  input type=\submit\ name=\cmdDelete\
 value=\Delete\nbsp;\n;

 }

 echo  input type=\submit\ name=\cmdCancel\ value=\Cancel\\n;

 echo  /td\n;

 echo /tr\n;

 echo /table\n;

 echo /form\n;

 ?



 ? include (body_end.inc); ?

 /html









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

 



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

[PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
I ran a print_r on it and this is the results

Array ( [txtPhoto] = Array ( [name] = g1.jpg [type] = image/pjpeg 
[tmp_name] = /tmp/php3qkA4A [error] = 0 [size] = 17008 ) )

The image received here must be inserted into a database as binary it looks 
like it.
Colin Guthrie [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Pieter du Toit wrote:
 Hi

 I have this weird problem, when i select a file to upload, the variable
 arrives as an array at the action php file, this is the code, and the
 variable name is txtPhoto

 I'd give a shorter example. People don't want to read through all your
 code..

 Also you shoudl post some sort of indication of what you are trying to
 do to get the results you describe... just saying the variable arrives
 as an array and we don't really know how you are accessing the 
 variable.

 A short example and expected/actual behaviour listing is good :)

 Col
 



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



[PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
This is my problem

Warning: fopen() expects parameter 1 to be string, array given in 
/usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

Colin Guthrie [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Pieter du Toit wrote:
 Hi

 I have this weird problem, when i select a file to upload, the variable
 arrives as an array at the action php file, this is the code, and the
 variable name is txtPhoto

 I'd give a shorter example. People don't want to read through all your
 code..

 Also you shoudl post some sort of indication of what you are trying to
 do to get the results you describe... just saying the variable arrives
 as an array and we don't really know how you are accessing the 
 variable.

 A short example and expected/actual behaviour listing is good :)

 Col
 



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



Re: [PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
This is my problem

Warning: fopen() expects parameter 1 to be string, array given in 
/usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

Angelo Zanetti [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Have you tried print_r($_FILES); to see all the values in the variable?

 Its difficult to see whats going on as you posted your whole file.



 -Original Message-
 From: Pieter du Toit [mailto:[EMAIL PROTECTED]
 Sent: 05 March 2008 12:38
 To: php-general@lists.php.net
 Subject: [PHP] Re: Variable post as array

 Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it 
 tells
 me that temp_name is also an array, but when i echo
 $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
 vardump i can see that temp name is [tmp_name]= string(14)
 /tmp/phplR1WSl and not an array by itself.

 Im going crazy here

 Pieter du Toit [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi

 I have this weird problem, when i select a file to upload, the variable
 arrives as an array at the action php file, this is the code, and the
 variable name is txtPhoto

 ? include (userpass.inc); ?

 html

 link rel=STYLESHEET type=TEXT/CSS href=specials.css

 titleSpecials Update/title

 /head

 ? include (body_begin.inc); ?

 ?

 echo form ENCTYPE=\multipart/form-data\ method=\POST\ name=\Edit
 Special\ action=\specials_proc.php\\n;

 echo input type=\hidden\ name=\keyClient_Id\
 value=\$g_client_id\;

 echo input type=\hidden\ name=\keySpecial\ value=\$special\;

 echo input type=\hidden\ name=\k_subsystem_id\
 value=\$k_subsystem_id\;

 echo table align=\center\ class=\EditView\ border=\0\
 cellspacing=\0\ cellpadding=\0\ width=\80%\\n;



 if ($special != )

 {

 $new = 0;

 echo tr class=\MainHeader\th colspan=\2\Edit
 Special/th/tr\n;

 $result = mysql(zululandcoza, select * from client_specials where
 client_id = $g_client_id and special = $special);

 if (list($client_id, $special, $description, $special_type, $price,
 $discount, $startdate, $enddate) = mysql_fetch_row($result))

 {

 }

 }

 else

 {

 $new = 1;

 echo tr class=\Header\th colspan=\2\h1New Special (this page 
 is

 undergoing maintenance, please try again later)/h1/th/tr\n;

 $result = mysql(zululandcoza, select max(special) from client_specials
 where client_id = $client_id);

 if (list($max_special) = mysql_fetch_row($result))

 {

 $special = $max_special + 1;

 }

 }



 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Specialnbsp;Number/td\n;

 if ($new)

 echo  td align=\left\ class=\Number\input type=\text\
 name=\txtSpecial\ maxlength=\5\ size=\5\
 value=\$special\/input/td\n;

 else

 echo  td align=\left\ class=\Number\input type=\text\
 name=\txtSpecial\ maxlength=\5\ size=\5\ value=\$special\
 enabled=\0\/input/td\n;

 echo /tr\n;

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Description/td\n;

 echo  td align=\left\ class=\Text\input type=\text\
 name=\txtDescription\ maxlength=\200\ size=\50\
 value=\$description\/input/td\n;

 echo /tr\n;

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Specialnbsp;Type/td\n;

 echo  td align=\left\ class=\Selection\\n;

 $optPRICE = ;

 $optDISC = ;

 $optFROM = ;

 if ($special_type == FROM)

 $optFROM =  SELECTED;

 elseif ($special_type == DISC)

 $optDISC =  SELECTED;

 else

 $optPRICE =  SELECTED;

 echo  select name=\cbxSpecial_Type\\n;

 echo  option value=\PRICE\$optPRICESpecial Price/option\n;

 echo  option value=\DISC\$optDISCDiscount %/option\n;

 echo  option value=\FROM\$optFROMFrom/option\n;

 echo  /select\n;

 echo  /td\n;

 echo /tr\n;

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Price/td\n;

 echo  td align=\left\ class=\Currency\input type=\text\
 name=\txtPrice\ maxlength=\20\ size=\10\
 value=\$price\/input/td\n;

 echo /tr\n;

 if ($k_subsystem_id == 2)

 {

 if (! $new)

 {

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\Current Photo/td\n;

 echo  td align=\left\ class=\Currency\img

 src=\showpic.php?keySystem_Id=2keyClient_Id=$g_client_idkeySpecial=$speci
 al\/td\n;

 echo /tr\n;

 }

 echo tr class=\Update\\n;

 echo  td align=\left\ class=\Prompt\New Photo/td\n;

 echo  td align=\left\ class=\Currency\input type=\file\
 name=\txtPhoto\ size=\50\/input/td\n;

 echo /tr\n;

 }

 echo tr class=\Footer\\n;

 echo  td colspan=\2\\n;

 if ($new)

 {

 echo  input type=\submit\ name=\cmdAdd\ value=\Add\nbsp;\n;

 }

 else

 {

 echo  input type=\submit\ name=\cmdUpdate\
 value=\Update\nbsp;\n;

 echo  input type=\submit\ name=\cmdDelete\
 value=\Delete\nbsp;\n;

 }

 echo  input type=\submit\ name=\cmdCancel\ value=\Cancel\\n;

 echo  /td\n;

 echo /tr\n;

 echo /table\n;

 echo /form\n;

 ?



 ? include (body_end.inc); ?

 /html









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

 



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

Re: [PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
This is line 49

$txtPhotoData = addslashes(fread(fopen($txtPhoto, r), 
filesize($txtPhoto)));

the $txtPhoto is the parameter

Angelo Zanetti [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 What is on line 49?

 What variable are you passing as the parameter?



 -Original Message-
 From: Pieter du Toit [mailto:[EMAIL PROTECTED]
 Sent: 05 March 2008 13:36
 To: php-general@lists.php.net
 Subject: [PHP] Re: Variable post as array

 This is my problem

 Warning: fopen() expects parameter 1 to be string, array given in
 /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

 Colin Guthrie [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Pieter du Toit wrote:
 Hi

 I have this weird problem, when i select a file to upload, the variable
 arrives as an array at the action php file, this is the code, and the
 variable name is txtPhoto

 I'd give a shorter example. People don't want to read through all your
 code..

 Also you shoudl post some sort of indication of what you are trying to
 do to get the results you describe... just saying the variable arrives
 as an array and we don't really know how you are accessing the
 variable.

 A short example and expected/actual behaviour listing is good :)

 Col




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

 



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



[PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
That is the problem, i can see the name of the file with $txtPhoto['name'] 
but when i use the same with temp_name, i get nothing, one weird thing is 
this [error] = 0 [size] = 17008  , what is that?

this is the code that is giving the problem
$txtPhotoData = addslashes(fread(fopen($txtPhoto, r), 
filesize($txtPhoto)));

And this is the error

Warning: fopen() expects parameter 1 to be string, array given in
 /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

I did not do the code im just trying to help out, if never use this kind of 
code to work with photos, i normally use move_uploaded_file and put the path 
in the databse, but it look like this code puts the photo in the database as 
binary or something.


Colin Guthrie [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Pieter du Toit wrote:
 I ran a print_r on it and this is the results

 Array ( [txtPhoto] = Array ( [name] = g1.jpg [type] = image/pjpeg
 [tmp_name] = /tmp/php3qkA4A [error] = 0 [size] = 17008 ) )

 The image received here must be inserted into a database as binary it 
 looks
 like it.

 on it is very vague dude. Be more specific... show code!!!

 From later posts it appears you are using register_globals to access the
 file as if it is a local variable.

 $txtPhotoData = addslashes(fread(fopen($txtPhoto, r),
 filesize($txtPhoto)));

 For file upload elements $txtPhoto will be an array. use
 $txtPhoto['tmp_name'] or something. It's all in the manual.

 PS just avoid register globals anyway, it's evil.

 Col
 



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



[PHP] Re: Variable post as array

2008-03-05 Thread Pieter du Toit
Thanks Colin this will help me, like i said im just trying to help its not 
my code and i dont work with photos like this, but i Do appreciate your 
patience with me.
Colin Guthrie [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Pieter du Toit wrote:
 That is the problem, i can see the name of the file with 
 $txtPhoto['name']
 but when i use the same with temp_name, i get nothing, one weird thing is
 this [error] = 0 [size] = 17008  , what is that?

 this is the code that is giving the problem
 $txtPhotoData = addslashes(fread(fopen($txtPhoto, r),
 filesize($txtPhoto)));

 And this is the error

 Warning: fopen() expects parameter 1 to be string, array given in
 /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 
 49

 I did not do the code im just trying to help out, if never use this kind 
 of
 code to work with photos, i normally use move_uploaded_file and put the 
 path
 in the databse, but it look like this code puts the photo in the database 
 as
 binary or something.

 OK, I'll try and spell it out seeing as the link to the PHP Manual
 didn't take ;)

 The variable $txtPhoto exists because you have register global option set.

 It will be the same value as $_FILES['txtPhoto'].

 This variable *is an array*. It is not meant to contain just a filename.

 Your fopen() statement assumes that this variable *is a string* and this
 is fundamentally wrong.

 The PHP Manula page cannot be more clear about what the various elements
 in this array mean:

 http://uk.php.net/manual/en/features.file-upload.php
 (here their element is called 'userfile', yours is called 'txtPhoto'.


 $_FILES['userfile']['name']
The original name of the file on the client machine.

 $_FILES['userfile']['type']
The mime type of the file, if the browser provided this information.
 An example would be image/gif. This mime type is however not checked
 on the PHP side and therefore don't take its value for granted.

 $_FILES['userfile']['size']
The size, in bytes, of the uploaded file.

 $_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file was
 stored on the server.

 $_FILES['userfile']['error']
The error code associated with this file upload. This element was
 added in PHP 4.2.0



 The ['name'] is the original name of the file the person uploaded. Your
 code tries to load the contents of the file into a variable. To do this,
 this simplest way is to do:

 $photoData = file_get_contents($_FILES['txtPhoto']['tmp_name']);

 Your code calls addslashes() on it but that's pretty braindead as it's
 binary data. If it's going into a database you'd be better formatting it
 using a database formatting function (e.g. mysql_real_escape_string) and
 not just relying on an ad-hoc method.

 HTHs

 Col





 



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



Re: [PHP] Schedule tasks from server

2008-02-04 Thread Pieter du Toit
I am using paradigmsolutions.co.za. I read about cronjobs, but aparently it 
is only available on unix or linux hosting, is this true?
Paul Scott [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Mon, 2008-02-04 at 16:30 +0200, Pieter du Toit wrote:
 Is there a way that i can schedule tasks on my webserver that will
 automatically fire on a certain time and date, without anyone visiting 
 the
 website?

 This domain is hosted by a ISP and not by me.

 Ask your ISP if they support cron jobs - that'll do it. If they don't
 then I would suggest moving ISP's.

 I see you have an SA mail address - which ISP are you using? I probably
 know the answer already if you can tell me ;)

 --Paul
 -- 
 .
 | Chisimba PHP5 Framework - http://avoir.uwc.ac.za   |
 ::







 All Email originating from UWC is covered by disclaimer
 http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
 

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



Re: [PHP] Schedule tasks from server

2008-02-04 Thread Pieter du Toit
98% of the pages is PHP, and i dont know if all my code is *nix compatable, 
it should be, but i dont want to take the risk by moving, i already have to 
much to do still.

Paul Scott [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Mon, 2008-02-04 at 16:46 +0200, Pieter du Toit wrote:
 I am using paradigmsolutions.co.za. I read about cronjobs, but aparently 
 it
 is only available on unix or linux hosting, is this true?

 Well, why not just host on *nix then? I see your site is a MS Frontpage
 one, but most linux based ISP's also support that anyway. That way you
 get the best of both worlds.

 Err, just one question though, if you are using FP, where does the PHP
 come in?

 --Paul







 All Email originating from UWC is covered by disclaimer
 http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
 

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



[PHP] Schedule tasks from server

2008-02-04 Thread Pieter du Toit
Hi people

Is there a way that i can schedule tasks on my webserver that will 
automatically fire on a certain time and date, without anyone visiting the 
website?

This domain is hosted by a ISP and not by me.

Thanks 

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



[PHP] Stop Download managers

2007-07-05 Thread Pieter du Toit
Hi

Is there a way to stop download managers on my php webpages? 

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



Re: [PHP] PHP not posting

2007-06-24 Thread Pieter du Toit
Nothing major here is the code:

?

if ($_POST['name']) {

echo name posted;

}

?

html

head

title/title

/head

body

form action=1.php method=post

Name:input type=text name=name

input type=submit value=submit

/form

/body

/html

Stut [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Pieter du Toit wrote:
 I installed PHP5 on iis and i can see hello world and phpinfo.

 When i right click the webpage and view source, i can see the php code, 
 and the form does not want to post the form details.

 Will appreciate any help.

 My amazing psychic abilities tell me that...

 ...you need to show us your code before we can have any chance of helping.

 -Stut

 -- 
 http://stut.net/ 

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



[PHP] PHP not posting

2007-06-24 Thread Pieter du Toit
Hi

I installed PHP5 on iis and i can see hello world and phpinfo.

When i right click the webpage and view source, i can see the php code, and 
the form does not want to post the form details.

Will appreciate any help. 

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



Re: [PHP] PHP not posting

2007-06-24 Thread Pieter du Toit
But why is the php code showing just like my code at the top when i right 
click the webpage and view source, i suspect this must be a php.ini setting 
or sonmething
Tijnema [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 6/24/07, Pieter du Toit [EMAIL PROTECTED] wrote:
 Nothing major here is the code:

 ?
   ^^ Do you have short tags enabled?, try ?php

 if ($_POST['name']) {

 Not the right way to check, you should use:
 if(isset($_POST['name']) {


 echo name posted;

 }

 ?
 html code

 If that still doesn't work, try a var_dump($_POST) at top of your
 script, and see if there's anything inside.

 Tijnema


 Stut [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Pieter du Toit wrote:
  I installed PHP5 on iis and i can see hello world and phpinfo.
 
  When i right click the webpage and view source, i can see the php 
  code,
  and the form does not want to post the form details.
 
  Will appreciate any help.
 
  My amazing psychic abilities tell me that...
 
  ...you need to show us your code before we can have any chance of 
  helping.
 
  -Stut
 
  --
  http://stut.net/

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




 -- 
 Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info 

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



[PHP] Spam using email on website

2006-11-06 Thread Pieter du Toit
Hi guys

I have a website that is being crawled or whatever and i have a submission 
form for an event.

I keep on getting random mail from this form.

I have even disabled the submit button on the form, but keep on getting it.

What can i do? 

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



[PHP] Pause script

2006-03-27 Thread Pieter du Toit
Hi

I want to pause script in php, in a while loop, so that a key must be 
pressed or a button must be clicked for the script to continue.

Is this possible, i had a look at some functions, but it is not what i want.

Can someone point me in a direction to search or maybe solve this problem 
for me.

Thanks 

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



[PHP] max unique number

2006-03-07 Thread Pieter du Toit
Hi guys

How do i get a unique max number from a mysql table column? 

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



[PHP] Need urgent help on post php long code

2005-04-21 Thread Pieter du Toit
I have the following code:
function display_setcom() {

global $config;

dsprint(display_setcom());

dprint($_SESSION[logged_in]);

$user_id = $_SESSION[logged_in];

$result = mysql_query(SELECT users.user_first_name, users.user_last_name, 
users.user_cell, users.user_idnom, users.user_email, users.user_adres1, 
users.user_adres2, users.user_pcode, users.user_city, users.user_prov FROM 
users WHERE users.user_id = '$user_id');

if (mysql_num_rows($result) == 1) {

$user_detail = check_user_details($user_id); //app.func.inc.php


dprint($user_detail);

if ($user_detail === true) {

$row = mysql_fetch_assoc($result);

dprint($row);

extract($row);




$ewal_result = mysql_query(SELECT DECODE(ewallet.ewal_pass, 
'{$config[password_password]}') AS ewal_pass FROM ewallet WHERE 
ewallet.user_id = '$user_id');

if (!mysql_error()) {

if (mysql_num_rows($ewal_result)  0) {

$row = mysql_fetch_assoc($ewal_result);

extract($row);

dprint($row);

}

} else {

dprint(mysql_error());

}


dprint($ewal_tosetcom);

$Co_ID = $config[e_wallet][Co_ID];

$Outlet = $config[e_wallet][Outlet];

$transac = get_nextid($_SESSION[database], transacs, tran_id, tran);

! this is where i echo all my required vars to post, and i get a value 
for each, but when i post to the next form only $co_id and $outlet is posted 
!!

echo Admin testingbr;

echo coid = .$Co_ID;

echo Outlet = .$Outlet;

echo user_email = .$user_email;

echo ewal_pass = .$ewal_pass;

echo user_id = .$user_id.$transac;

echo  END

p class=WARNThe following details are used for your credit card 
transactions,brif they are incorrect or incomplete, please go to a 
href=index1.php?display=detailsMy Details/a and update your 
details.brIf it is correct, you can click on the button below to TopUp 
eWallet/p

form action=testvars.php method=post name=setcom

table CLASS=PREDICT border=1 align=center

tr class=minmaxtxt

tdName:/td

td class=minmaxtxtcoinput name='Name' type='hidden' maxlength='25' 
size='35' value=$user_first_name $user_last_name$user_first_name 
$user_last_name/td

/tr

tr class=minmaxtxt

tdCellphone Number:/td

td class=minmaxtxtcoinput name='Tel' type='hidden' maxlength='10' 
size='15' value=$user_cell$user_cell/td

/tr

tr class=minmaxtxt

tdID Number:/td

td class=minmaxtxtcoinput name='Addonfields' type='hidden' 
maxlength='13' size=17 value=Identity:$user_idnom$user_idnom/td

/tr

tr class=minmaxtxt

tdAddress:/td

td

table border=1 class=PREDICT

tr class=minmaxtxt

tdStreetname  Number:/td

td class=minmaxtxtcoinput name='Address1' type='hidden' maxlength='255' 
size='15' value=$user_adres1$user_adres1/td

/tr

tr class=minmaxtxt

tdSuburb/Area:/td

td class=minmaxtxtcoinput name='Address2' type='hidden' maxlength='255' 
size='15' value=$user_adres2$user_adres2/td

/tr

tr class=minmaxtxt

tdPost/Zip Code:/td

td class=minmaxtxtcoinput name='Zip' type='hidden' maxlength='9' 
size='10' value=$user_pcode$user_pcode/td

/tr

tr class=minmaxtxt

tdCity:/td

td class=minmaxtxtcoinput name='City' type='hidden' maxlength='25' 
size='15' value=$user_city$user_city/td

/tr

tr class=minmaxtxt

tdProvince/State:/td

td class=minmaxtxtcoinput name='State' type='hidden' maxlength='25' 
size='15' value=$user_prov$user_prov/td

/tr

tr class=minmaxtxt

tdCountry/td

td class=minmaxtxtco

select name=Country

option value=ZASouth Africa/option

/select

/td

/tr

/table

/td

tr class=ROW1

/table

br

table class=PREDICT border=1 align=center

tr class=minmaxtxtco

tdTopUp Amount:/td

tdinput type=text name=CC_amount

/tr

tr class=minmaxtxt

td colspan=2 align=center

input type=submit name=register value=TopUp eWallet onClick=if 
(!ValidAmount(setcom.CC_amount.value)) { alert('Please enter a valid 
amount'); return (false);};

/td

/tr

/table

input type=hidden name=Co_ID value=$Co_ID

input type=hidden name=Outlet value=$Outlet

input type=hidden name=UserName value=$user_email

input type=hidden name=Password value=$ewal_pass

input type=hidden name=Reference value=$user_id:$transac

input type=hidden name=Lang value=ENG


END;

if ($tosetcom === 0) { //If the user has not been registered yet.

print(\t\t\tinput type=\hidden\ name=\ConfirmPassword\ 
value=\$ewal_pass\\n);

}

print(\t\t/form\n);

} else {

print(p class=\WARN\Your details are not complete. Please update them 
at a href=\index1.php?display=details\My Details/a before you can 
TopUp your account/p\n);

}

} else {

$_SESSION[error] .= p class=\WARN\Could not fetch user details, 
please try again later./p\n;

dprint(mysql_error());

}

}

i really need help here, have a deadline

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



[PHP] htaccess file

2005-04-21 Thread Pieter du Toit
Is there any way that i can see if using htaccess file is enabled on server 
without contacting my isp.

I created a htaccess file and ftp'd it to the server with the 
register_globals flag set to 0:

this is the htaccess code

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

Limit GET POST

order deny,allow

deny from all

allow from all

/Limit

Limit PUT DELETE

order deny,allow

deny from all

/Limit

AuthUserFile /home/predicta/public_html/_vti_pvt/service.pwd

AuthGroupFile /home/predicta/public_html/_vti_pvt/service.grp

php_flag engine off

AllowOverrid ALL

php_admin_flag register_globals 0

and this is what happens

Internal Server Error
The server encountered an internal error or misconfiguration and was unable 
to complete your request.
Please contact the server administrator, [EMAIL PROTECTED] and 
inform them of the time the error occurred, and anything you might have done 
that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 500 Internal Server Error error was encountered while trying 
to use an ErrorDocument to handle the request.




Apache/1.3.33 Server at www.predictabid.com Port 80

I suppose this means that htaccess use is not enabled?

If this is the case, what else can i use to set register_globals to on?

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