[PHP] Class not returning value
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: 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 "; 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 . ""; } 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=0&GSM=' . $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
Sorry i found the problem, need to do this: public function getResult() { $this->processRequest(); return $this->responseArray; } ""Pieter du Toit"" 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: > > /** > * > * @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 "; >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 . ""; >} 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=0&GSM=' . $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
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" 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: >> > >> /** >> * >> * @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 "; >> 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 . ""; >> } 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=0&GSM=' . $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; >> } >> retur
[PHP] Need urgent help on post php long code
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 testing"; 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 The following details are used for your credit card transactions,if they are incorrect or incomplete, please go to My Details and update your details.If it is correct, you can click on the button below to TopUp eWallet Name: $user_first_name $user_last_name Cellphone Number: $user_cell ID Number: $user_idnom Address: Streetname & Number: $user_adres1 Suburb/Area: $user_adres2 Post/Zip Code: $user_pcode City: $user_city Province/State: $user_prov Country South Africa TopUp Amount: END; if ($tosetcom === 0) { //If the user has not been registered yet. print("\t\t\t\n"); } print("\t\t\n"); } else { print("Your details are not complete. Please update them at My Details before you can TopUp your account\n"); } } else { $_SESSION["error"] .= "Could not fetch user details, please try again later.\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
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* order deny,allow deny from all allow from all order deny,allow deny from all 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
Re: [PHP] Schedule tasks from server
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
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
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
Re: [PHP] Re: Variable post as array
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 >> >> >> >> >> >> >> >> Specials Update >> >> >> >> >> >> > >> echo "> Special\" action=\"specials_proc.php\">\n"; >> >> echo "> value=\"$g_client_id\">"; >> >> echo ""; >> >> echo "> value=\"$k_subsystem_id\">"; >> >> echo "> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n"; >> >> >> >> if ($special != "") >> >> { >> >> $new = 0; >> >> echo "Edit >> Special\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 "New Special (this page >> is > >> undergoing maintenance, please try again later)\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 "\n"; >> >> echo " Special Number\n"; >> >> if ($new) >> >> echo " > name=\"txtSpecial\" maxlength=\"5\" size=\"5\" >> value=\"$special\">\n"; >> >> else >> >> echo " > name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\" >> enabled=\"0\">\n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo " Description\n"; >> >> echo " > name=\"txtDescription\" maxlength=\"200\" size=\"50\" >> value=\"$description\">\n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo " Special Type\n"; >> >> echo " \n"; >> >> $optPRICE = ""; >> >> $optDISC = ""; >> >> $optFROM = ""; >> >> if ($special_type == "FROM") >> >> $optFROM = " SELECTED"; >> >> elseif ($special_type == "DISC") >> >> $optDISC = " SELECTED"; >> >> else >> >> $optPRICE = " SELECTED"; >> >> echo " \n"; >> >> echo " Special Price\n"; >> >> echo " Discount %\n"; >> >> echo " From\n"; >> >> echo " \n"; >> >> echo " \n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo " Price\n"; >> >> echo " > name=\"txtPrice\" maxlength=\"20\" size=\"10\" >> value=\"$price\">\n"; >> >> echo "\n"; >> >> if ($k_subsystem_id == 2) >> >> { >> >> if (! $new) >> >> { >> >> echo "\n"; >> >> echo " Current Photo\n"; >> >> echo " > > src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$speci > al\">\n"; >> >> echo "\n"; >> >> } >> >> echo "\n"; >> >> echo " New Photo\n"; >> >> echo " > name=\"txtPhoto\" size=\"50\">\n"; >> >> echo "\n"; >> >> } >> >> echo "\n"; >> >> echo " \n"; >> >> if ($new) >> >> { >> >> echo " \n"; >> >> } >> >> else >> >> { >> >> echo " > value=\"Update\"> \n"; >> >> echo " > value=\"Delete\"> \n"; >> >> } >> >> echo " \n"; >> >> echo " \n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo "\n"; >> >> ?> >> >> >> >> >> >> >> >> >> >> >> >> > > > > -- > 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
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
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
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 >> >> >> >> >> >> >> >> Specials Update >> >> >> >> >> >> > >> echo "> Special\" action=\"specials_proc.php\">\n"; >> >> echo "> value=\"$g_client_id\">"; >> >> echo ""; >> >> echo "> value=\"$k_subsystem_id\">"; >> >> echo "> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n"; >> >> >> >> if ($special != "") >> >> { >> >> $new = 0; >> >> echo "Edit >> Special\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 "New Special (this page >> is > >> undergoing maintenance, please try again later)\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 "\n"; >> >> echo " Special Number\n"; >> >> if ($new) >> >> echo " > name=\"txtSpecial\" maxlength=\"5\" size=\"5\" >> value=\"$special\">\n"; >> >> else >> >> echo " > name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\" >> enabled=\"0\">\n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo " Description\n"; >> >> echo " > name=\"txtDescription\" maxlength=\"200\" size=\"50\" >> value=\"$description\">\n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo " Special Type\n"; >> >> echo " \n"; >> >> $optPRICE = ""; >> >> $optDISC = ""; >> >> $optFROM = ""; >> >> if ($special_type == "FROM") >> >> $optFROM = " SELECTED"; >> >> elseif ($special_type == "DISC") >> >> $optDISC = " SELECTED"; >> >> else >> >> $optPRICE = " SELECTED"; >> >> echo " \n"; >> >> echo " Special Price\n"; >> >> echo " Discount %\n"; >> >> echo " From\n"; >> >> echo " \n"; >> >> echo " \n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo " Price\n"; >> >> echo " > name=\"txtPrice\" maxlength=\"20\" size=\"10\" >> value=\"$price\">\n"; >> >> echo "\n"; >> >> if ($k_subsystem_id == 2) >> >> { >> >> if (! $new) >> >> { >> >> echo "\n"; >> >> echo " Current Photo\n"; >> >> echo " > > src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$speci > al\">\n"; >> >> echo "\n"; >> >> } >> >> echo "\n"; >> >> echo " New Photo\n"; >> >> echo " > name=\"txtPhoto\" size=\"50\">\n"; >> >> echo "\n"; >> >> } >> >> echo "\n"; >> >> echo " \n"; >> >> if ($new) >> >> { >> >> echo " \n"; >> >> } >> >> else >> >> { >> >> echo " > value=\"Update\"> \n"; >> >> echo " > value=\"Delete\"> \n"; >> >> } >> >> echo " \n"; >> >> echo " \n"; >> >> echo "\n"; >> >> echo "\n"; >> >> echo "\n"; >> >> ?> >> >> >> >> >> >> >> >> >> >> >> >> > > > > -- > 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
Re: [PHP] Re: Variable post as array
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
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
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] PHP not posting
Nothing major here is the code: Name: "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
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
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 >> if ($_POST['name']) { > > Not the right way to check, you should use: > if(isset($_POST['name']) { > >> >> echo "name posted"; >> >> } >> >> ?> > > > 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] Stop Download managers
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
[PHP] Spam using email on website
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] max unique number
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] Pause script
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