php

SimpleXMLElement Change Attribute Value

I love SimpleXMLElement-- it's great as a XML Element Parser.So I am thinking is there an XML writer-- the one that changes the attribute values, for example, changing <?xml version="1.0"?> <a b="One Two"> <c>Three Four</c> <d>Five Six</d> </a> to <?xml version="1.0"?> <a b="One Two"> <c>seven</c> <d>eight</d> </a> ...

How do I make a regex not 'swallow' a character?

I have a text file like so {word} definition {another word} another definition {word} they don't have to be on different lines The regex I was using was $regex = '/\{([a-z]+?)\}(.+?)\{/i'; This however, causes problems in that it swallows the last brace {, and then it won't match the next { in the next word. To demonstrate, I ...

Best practice for using fopen() or file_get_contents() to retreive web pages.

I am looking for some advice on the best way to retrieve information from a web page (my own site) and then search through that information to find a certain text. Keeping in mind that some of the servers that run PHP/Joomla do not have cURL enabled, I don't want to cause any unexpected errors. I've looked at both fopen() and file_get_...

How can I display the full text of a query created by PDO?

I'm creating a SQL query with PDO in PHP. Unfortunately, there seems to be an error in my query. I've tried $query->errorInfo(), but that only gives me a little bit of the error message ("There is an error in your syntax near..."). How can I display the entire query that PDO is passing to my database? TIA. ...

What would be a good sample project to ask a prospective programmer to code during the hiring process?

My understanding is that asking for a work sample is a good way to determine if someone has the skillset you are looking for, as some people just interview well. So I want to ask potential developers to write some sample code for me. I'm looking for ideas on what kind of small project would be something they could do in an hour or two, ...

Get results from my own and "friends" posts

Hi there! I have a problem that I can't figure out myself. I've tried using LEFT JOIN etc but nothing seems to work. I'm using MySQL so you know. I'm building a little blogportal for me and my friends and all users have their own blog. database: users: id, username, password, etc blog: id, title, text, user_id, etc relations fo...

Php, date manipulation?

Hi, I am new to php. And I would like to know some of the date manipulation things in php. // Get Current date $date = date("Y-m-d"); What if I want to subtract current date and a specific date, lets say "today - 2008-06-26"? Q1: How to do date math manipulation (add, minus, multply etc) in php? Q2: If today, a subscriber subscrib...

executing php script from C program and store the results in to a variable

I would like to execute php script from the C Program and store the returning content in to a C variable. I tried like following but it doesnt works: C Code: printf("calling php function\n"); execl("/usr/bin/php -q", "/var/www/html/phpinfo.php", NULL); printf("End php function\n"); Php Code: <?php echo "hello"; ?> Envir...

How can I create separate web directories for each application in symfony?

For instance, I have two applications: 'frontend' and 'backend'. I'd like my /web directory to be set up so that '/web/frontend' serves the 'frontend' assets, and '/web/backend' serves the 'backend' assets without having to go modify all the image paths, etc. ...

Is it dangerous thing to view access log without sanitizing via web browser?

Is it dangerous thing to view access log without sanitizing via web browser? I am considering to record access log, and I am considering to view it via wev browser, but if attacker modifies his remote host or user agent or something, can he attack to me? By inserting attacking code into his remote host or user agent or ect. So do I ne...

correct way to upload image to database

i know some of you are going to say that this isnt the correct way but im on a tight deadline to finish an application and as of now i cant go back and modify the code to store the images in a directory. now that thats cleared the question i had is i inserted an image into the database by typing this. (dont mind the class security ca...

Object Oriented Programming, extending properties

Ok this is not just a PHP question, but I have this problem in PHP so I will post the example in PHP. Example: I have three classes, say, data_abstract, person, and student. Now, I have one array of data related to each of those objects. class person extends data_abstract { protected $data; //name, gender, etc } class student ex...

How to set a file in cron job

I need to run a php file every minute so I tried to set a cronjob from the cpanel but it's sending mail with the message "could not open the input file:" My php file is inside public_html/schoolerp/cron.php I did: /usr/local/bin/php -f /public_html/schoolerp/cron.php Am I doing something wrong please tell me if I am setting it right...

client->soapFunction(); and soapCall not returning data but getLastResponse does

The code below correctly returns the XML from the soap sever that I'm accessing. If I echo $client->Function(); however it returns Object id #2. $client=new SoapClient("http://blackbird.integrated.local/PricingTool/WebService.asmx?WSDL", array('trace' => true)); //echo $client->__soapCall('TestSOAP', array('YesNo' => '1')); $client->...

How to update adobe air application after install ?

how to update air application after install in system . updated not be reinstall will be automatically ? is it possiable? ...

PHP Sockets or Python, Perl, Bash Sockets?

I'm trying to implement a socket server that will run in most shared PHP hosting. The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run on the majority of shared host...

PHP calls to external programs all fail with exit code 127

echo system("/usr/bin/whoami", $ret); echo $ret; PHP 4.3.9 on Apache 2.0.52, CentOS 4.5. Safe mode is off, I can run programs as the apache user account from the command line, but all programs run from PHP fail with exit code 127. ...

Google Search API Backend

Hey guys, I was wondering if any of you know how to implement a backend system that will retrieve SEO information from Google (Website Ranking, #ocurrences in the first X results in google, etc). I know Google AJAX Search API (code.google.com/apis/ajaxsearch/) will allow you to retrieve the content without having to "wget" or "curl", ...

MySQL import in phpmyadmin (CSV) chokes on quotes

I am trying to import a .csv file into a MySQL table via phpMyAdmin. The .csv file is separated by pipes, formated like this: data|d'ata|d'a"ta|dat"a| data|"da"ta|data|da't'a| dat'a|data|da"ta"|da'ta| The data contains quotes. I have no control over the format in which I recieve the data -- it is generated by a third party. The pro...

LinkedIn type friends connection required in php

Hi, I am creating a custom social network for one of my clients. In this I am storing the friends of a user in the form of CSV as shown below in the user table uid user_name friends 1 John 2 2 Jack 3,1 3 Gary 2,4 4 Joey 3 In the above scenario if the logged in user ...