[PHP] Php ignores if statement
I recently started coding online and i have the weirdest response, my code is: "; print (gettype($id)); if ($id = "add" ) { echo "is add"; exit; } if ($id = "own" ) { echo "id is own"; exit; } if ($id = "all" ) { echo "id is all"; exit; } ?> $id in this case = "own", but it totally ignores this value and uses the first if statement and treats $id as if it has a value of "add". I am very frustrated and i really hope someone can help me. The server is linux, and php version 4.1.2 Thanks
[PHP] Trapping PHP errors
Hi all, is there a way to execute a custom function as soon as an error happens in PHP? I looked at the set_error_handler function, but it doesn't seem to trap all the errors. What I want to achieve is to execute a function that mails me the error everytime an error happens. Cheers, Pieter
[PHP] PHP and MySQL
Hello, we're using our MySQL database quite extensively from our PHP scripts, but sometimes everything stops working and it says "Too many connections". Is there a problem with MySQL support from within PHP? Doesn't it close its connections with the database when the script stops executing? Is there anything I can do to resolve this problem? Regards, Pieter Philippaerts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: PHP and MySQL
Unfortunately, I can't access these settings. It's not our computer that hosts our website. Regards, Pieter Philippaerts "Richard Lynch" <[EMAIL PROTECTED]> wrote in message 01e501c138ce$f3008300$6401a8c0@Lynchux100">news:01e501c138ce$f3008300$6401a8c0@Lynchux100... > Options: > Increase the settings in MySQL that limit how many databases can be open at > once. > Decrease the number of Apache children running. > > Basically, as long as you have more Apache children than MySQL connections > available, you can get this message. > > Actually, have a few spare MySQL connections, so you can telnet/SSH in and > use the monitor as well, and cron jobs using MySQL can run. > > -- > WARNING [EMAIL PROTECTED] address is an endangered species -- Use > [EMAIL PROTECTED] > Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm > Volunteer a little time: http://chatmusic.com/volunteer.htm > - Original Message - > From: Pieter Philippaerts <[EMAIL PROTECTED]> > Newsgroups: php.general > To: <[EMAIL PROTECTED]> > Sent: Friday, September 07, 2001 11:30 PM > Subject: PHP and MySQL > > > > Hello, > > we're using our MySQL database quite extensively from our PHP scripts, > > but sometimes everything stops working and it says "Too many connections". > > Is there a problem with MySQL support from within PHP? Doesn't it close > > its connections with the database when the script stops executing? > > Is there anything I can do to resolve this problem? > > > > Regards, > > Pieter Philippaerts > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: PHP and MySQL
We have never used mysql_pconnect. Regards, Pieter Philippaerts "Stefan De Wal" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > check your connection string and if it something like mysql_pconnect change > it in mysql_connect > > Stefan de Wal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mysql + addslashes + stripslashes
Hi, I have a similar problem at the moment. I was waiting to scrape together an example, but since you posted first I will jump into the discussion now. My problem is that I have a large array (without any funnies like self-referencing) getting serialized. There are some funnies in the string fields though (like `'`s etc). After making a roundtrip to the mysql database, things start to get bad on me since I cannot unserialize the text anymore. This only happens for some of the arrays that I have. Other arrays with similar data can get serialized and unserialized just fine. I do suspect though, that the problem lies with how I am using addslashes and how I am not using it. Any definitive help would be much appreciated. pieter On 5/16/05, Petzo <[EMAIL PROTECTED]> wrote: > > Hi, > > My question is about the norlmal behaviour of PHP and MYSQL but I cant > explain it without a simple example. Thank you for reading: > > I have the following code: > > print $t = $_POST['txt']; > print $t = addslashes($t); > > @ $db = mysql_pconnect(xxx,xxx,xxx); > mysql_select_db('test'); > > $q = "update ttable set ffield='$t'"; > mysql_query($q); > > $q = "select * from ttable"; > $result = mysql_query($q); > $bo = mysql_fetch_array($result); > > print $t = $bo['ffield']; > print $t = stripslashes($t); > ?> > > > from a HTML form I send variable: > > ' \ \' \\ \\\ > > > after addshashes it becomes: > > \' \\ \\\' \\ > > > after that it gets in the database > > but after I get it out it becomes: > > ' \ \' \\ \\\ > > (without the backslashes!) > > and ofcourse after stripslashes it gets messed-up: > > ' ' \ \ > > > So my question is if this is a normal behaviour for PHP+MYSQL or it may > vary > indifferent conficurations or versions of both php or mysql. > It's not a bad thing to be like that but I wonder if my code will behave > the > same at most systems. > > Thank you very much > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- "Maybe I'm a little bit crazy, but I can't decide if it's psychotic or neurotic. You know the difference, don't you? A psychotic thinks that 2 + 2 = 5. A neurotic knows that 2 + 2 = 4, but it makes him nervous." - Larry Wall, The State of the Onion (speech) 2004. http://www.perl.com/pub/a/2004/08/18/onion.html
[PHP] php addslashes etc
Hi, First of, sorry for the attachment. It is a screenshot of the output of the following code. It also shows the contents of the array data in question. I have the following piece of actual code: // $arrayData is the data in an array form $arrayData = ArrayIzeDbResult( $db2 ) ; // we want to capture the printed output ob_start(); $data = addslashes( serialize( $arrayData ) ); print $testdata; $printeddata = ob_get_contents(); // this next line does not work since the results of unserialize // is bool(false) ob_end_flush(); print "\nNumber, the first\n"; print_r( unserialize( stripslashes( $printeddata ) ) ); // however, this next line DOES work print "\nNumber, the second\n"; print_r( unserialize( stripslashes( addslashes( serialize( $arrayData ) ) ) ) ); I am trying to store the serialized array into a database (mysql) but on reading it out again, it cannot unserialize. This piece of code, even though it doesn't use the db, shows the problem perfectly. The other funny thing is that not all arrays break when I am doing this. I have quite a lot of similar arrays that work find when you do this. This one however needs to work too ;) Regards, Pieter Breed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] start-condition stack underflow
Fatal error: start-condition stack underflow Have not seen this error in 4 years of programming PHP. Came up in looping SMTP socket test. Anyone knows what this means? Thanks Buiten Westen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I need unique max number
Hi all I have data in one field in a database, all is numbers that can be duplicated. 200, 200, 100, 50, 30. i need to get all data from this field, terminate the duplicates and get the max nuber that is not a duplicate, in the numbers above that would be 100. I had a look at array_unique, but i'm not sure if this is the right function for this. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[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
[PHP] Refresh and retry when using back button on IE
Hi I need to know if there is any code that can be used to get rid of the refresh and retry when using the back button in internet explorer. Every time i get info from the database and display the result, and i use the back button it says Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button. and the when you refresh it says: The page cannot be refreshed without resending the information. Click retry to send the information again, or click cancel to return to the page that you were trying to view. This is very irritating. Can someone tell me how to resend the info automatically, please Thanks Pieter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What's this
Hi This has me confused, is this Java or a php class, a constant or what?, i have never seen this kind of action. In what type of file will i find the "S_MODE". Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: What's this
This type of action is used in a lot of files in "PHPbb". I need to change someting in the "Jump to" at the bottom of Search and memberlist pages. "Pieter From Sa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > > This has me confused, is this Java or a php class, a constant or what?, i > have never seen this kind of action. > > > > In what type of file will i find the "S_MODE". > > Thanks -- 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