php

How to do this (PHP) in python or ruby?

My app takes a loooong list of urls, and split it in X (where X = $threads) so then I can start a thread.php and calculate the urls for it. Then it does GET and POST request to retrieve data I am using this: for($x=1;$x<=$threads;$x++){ $pid[] = exec("/path/bin/php thread.php <options> > /dev/null & echo \$!"); } For "threading"...

Can't count an array in PHP

I've encountered a very odd issue in a class I'm creating. Here is a snippet of the class below and it's output: class WeirdHappenings { protected $filters_list = array(); ... function build() { $filters_count = count($this->filters_list); echo "<pre>"; var_dump($this->filters_list); echo "...

PHP Can't upload file in directories higher than it

Hello, My PHP script that uploads a file, cannot do so in directories at a higher level than itself. For example: it will save in upload/ (a relative path at the same level as the script), but not in /usr/local/hello/ even though the file permissions are exactly the same. There are no issues with max upload size, max post size, executi...

UPDATE table problem with email address

Hi, I'm trying to update a email field in Mysql through php. i keep getting this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@yahoo.com, The cell in Mysql is varchar(100). The e-mail addres is typed in from a text box. $insert_fbacc="UPDA...

ZEUS Server - Wordpress prettier URL rewrites with an exception?

hey guys, i bet there are a lot of regexp and rewrite nerds out there. I have a kind of a big problem with a current wordpress website i'm working on. my hosting provider gave me the following script to enable prettier urls for my wordpress blog on their zeus servers. this works really fine except i'm having one problem: heres the cod...

preg_replace to strip out non-printing characters seems to remove all foreign characters as well

I'm using the following regex to strip out non-printing control characters from user input before inserting the values into the database. preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $value) Is there a problem with using this on utf-8 strings? It seems to remove all non-ascii characters entirely. ...

Is this an OK test to see if a variable is set

Hello, Yesterday, I posted an answer to a question that included several (unknown to me at the time) very bad code examples. Since then, I've been looking at my fundamental knowledge of PHP that allowed me to think that such code is possible. This brings me to a question that I can't seem to find an answer to: If I want to check for ...

How do I access POST parameters in actions.class.php in symfony 1.4?

I'm still fairly new to symfony, so my apologies if this is a stupid question. I'm using symfony 1.4 with Doctrine. My colleague wrote a JavaScript to make a report from our client side widget to our server: $j.post(serverpath, {widget_id:widget_id, user_id:user_id, object_id:object_id, action_type:action_type, text_value:stuff_to_repor...

How to use a layout for emails in Zend Framework

I would like to use a layout for the emails I'm sending out. I'm currently usine Zend Layout for the web pages, but would like to theme my emails as well. Here is what I've tried. This is my function that sends the email $layout = Zend_Layout::getMvcInstance(); $this->_view->render($template); $html = $layout->render('emai...

PHP: ftp_ssl_connect wont work?

is there anything i've missed on the PHP manual. the difference between ftp_connect and ftp_ssl_connect is just the method-name, right. somehow i'm not able to connect to my ftp-server with ftp_ssl_connect but with ftp_connect everything works fine. I'm using the exact same code. any ideas what i could do wrong here? regards matt ...

SimpleXML and PHP XPath expression not returning correct data

The following PHP code: <html> <?php $name = Secrezy; $server = Sunstrider; $raidurl='http://eu.wowarmory.com/character-achievements.xml?r='.$server.'&amp;cn='.$name.'&amp;c=168'; print_r($raidurl); // This is to check if the link is valid. Follow the link printed here and you should find a valid XML page echo "<br>"; $xmlraid =...

Preventing JavaScript Injections in a PHP Web Application

What are the measures needed to prevent or to stop JavaScript injections from happening in a PHP Web application so that sensitive information is not given out (best-practices in PHP, HTML/XHTML and JavaScript)? ...

What chr(int).chr(int) decompositions do these 4 letters have? Ș, ș, Ț, ț

I really need to get WordPress to "sanitize" them and replace them with S, s, T, t when it creates post slugs. I know the code for this is in wp-includes/formatting.php and it's the "remove_accents" function, but I can't for the life of me figure how these letters decompose into chr(int).chr(int), and I would really love to find out sin...

Outputting multiple results from tables

The recipe db continues... categories cid | category_name 1 | desserts 2 | cakes 3 | biscuits recipes id | recipe_name 1 | black forest cake 2 | angel cake 3 | melting moments 4 | croquembouche 5 | crepes suzette ingredients iid | ingredient_code | ingredient_name | ingredient_brand 1 | abc201 | self-ra...

Libraries/Examples of Hover or Click Menus for web pages/apps, where to start?

I'm changing the layout of a web app that we are developing internally and have identified a few spots where a menu would be much more helpful than our currently layout. The project is currently built on Zend Framework and jQuery. Are they any good examples of context menus, or just menus in general that I should check out for inspiratio...

Foreach loop, but for first key do something else

Sorry if this is confusing. It's tough for me to put into words having beginner knowledge of PHP. I'm using the following foreach loop: foreach ($_POST['technologies'] as $technologies){ echo ", " . $technologies; } Which produces: , First, Second, Third What I want: First, Second, Third All I need is for the loop to ...

PHP code for checking email says .info domains are invalid

I have the following PHP code that checks if an email is valid: if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email)) return true; Works great but I found out today that if I try validate a .info email, it says it's invalid. Any ideas what I need to add/modify to make it return .info e...

class constructor

I am trying to understand how classes and functions work more. So i have written a class with 2 functions inside it. Then initiated the class with $fifaadmin = new FifaAdmin; When I try to call this class from another page i get the following error Call to a member function leagueToReplace() on a non-object What am i doing wron...

another twitter oAuth cURL access token request that fails

The following function gives a validation error instead of the token: failed to validate oAuth signature and token function request_token() { // Set url $url = $this->site.$this->request_token_path; // http://api.twitter.com/oauth/request_token // Params to pass to twitter and create signature $params['oauth_consumer_...

How to make a javascript/php chatroom more efficient in terms of load time and sql communication

Right now the setup for my javascript chat works so it's like function getNewMessage() { //code would go here to get new messages getNewMessages(); } getNewMessages(); And within the function I would use JQuery to make a get post to retrieve the messages from a php scrip which would 1. Start SQL connection 2. Validate that i...