php

2 IP addresses for 1 website

I have a website that is totally in French. I plan to have an english version since few months. Everything work fine, people can switch their language and the session handle their language. The problematic is that now I have bought a domain that is different of the french one and I guess it will require to point to the same sub-domain o...

How can I match ALL terms using Regular Expressions in PHP?

I figured out how to check an OR case, preg_match( "/(word1|word2|word3)/i", $string );. What I can't figure out is how to match an AND case. I want to check that the string contains ALL the terms (case-insensitive). ...

Twitter, change protected status with PHP

Can anyone suggest, with examples, how I might go about changing my protected tweet setting from False to True via PHP. What I'd like to do is Switch my protected tweet status to: True, post a update and then switch it back to False. I beleive the URL required is thus: http://twitter.com/account/update_profile.xml ... <protected>fals...

server is disconneting database....

database get connected successfully....but... here is my code <?php $host = 'localhost'; $user = 'root'; $pass = ''; $db = 'databasename'; mysql_connect($host, $user, $pass) or die ("Database Not Connected"); mysql_select_db($db) or die ("Database Not Fount"); ?> but the database is regularly disconnecting and connecting after 30-4...

Twitter Search - Multiple searches based on CSV in Text file

I have a log file which stores search terms I want to run agasint a twitter search. I have the following which basically searches for 1 value, however the CSV contains a number of values to search. How can I adjust the below to find the file: searchterms.txt Read in the comma seperated values, then search each one independantly. Als...

Is there any function to check if a directory or folder exist in PHP?

I want to check if there is a directory exist or not before uploading a file. If the directory does not exist return FALSE. Does is_dir do the work? ...

Zend Framework, phpUnit and Doctrine cause problems

Hello everyone. First some basic info: Ubuntu latest version Zend Framewrok 1.9.6 Doctrine 1.2.1 Php unit latest version I have been following this and thistutorial to set up my zend envrionment with doctrine and phpUnit. My environment is not an emtpy project since I had done some developments before I configured doctrine and php...

Creating CFArray from MySQL Result Array

Is there an easy way to dump an array returned from mysql_fetch_row into a CFArray? (part of the PHP implementation of CFPropertyList) I'm bummed by the lack of documentation on CFPropertyList for PHP. Iterating through each item in the array seems inefficient. I'm open to using a different mysql_fetch_... command. I'd like to just say:...

Check if user closed the page in PHP?

I made a chat using PHP and JavaScript chat and there is a disconnect button which removes user from the chat removing him from user list first. But if the user closes browser then he will remain in the user list. How do I check if he left? This must be done without putting any handles on page closing in JS because if user kills the bro...

Using the PHP -W flag in a batch file

I'm trying to remove all white space and code comments from my .php files by using the -W flag available from the PHP CLI. I'm using a batch file to recursively loop through each php file in my project. The batch command looks like: FOR /F "tokens=*" %%G IN ('DIR /B /A-D /S *.php') DO "%php-exe-path%/php.exe" -w %%G > %%G This just ...

mysql compare table values

i am creating a poll in php. i have a table with an id column. when a user submits a choice, i want the php to first query the db and check whether the table "id" has the id of the current user. i am pretty new at mysql. can someone help me with the query? thanks a lot. ...

Should I use sessions or go with what I have now ?

I have a classifieds website where users may insert ads. There is a insert-ad section (PHP based). In the insert section, firstly users enter specified data and fill in all fields of the form, then they click the "Preview Ad" and the ad is previewed. The preview page is another php page which puts all the form fields from the first 'pu...

Associating tables in PHP + MySql

So, i'm creating a money management system. My database has 2 tables: main(id,timestamp,value1,value2) and fields(value1,value2). Value1 and value2 are the categories in which the money are spent. In fact, the script display a table where the rows are the days and the columns are the fields where the money have been spent into (sport, ...

Is there any risk of injection in PHP's mail() function?

I am wondering if there is any potential security risk from the following code. I use this on my blog whenever a user submits a comment, it will send me a text message: mail('[email protected]', '', "Comment posted by $name: $comment", "From: [email protected]"); Where $name and $comment are user-entered ...

Why It is not possible to serialize PHP built-in objects ?

I have tried to unserialize a PHP Object. Warning: unserialize() [function.unserialize]: Node no longer exists in /var/www/app.php on line 42 But why was that happen? Even if I found a solution to unserialize simplexml objects, its good to know why php cant unserialize objects? To serialize simplexml object i use this function func...

jquery POST method callback function query

$("#submit_js").click(function() { var commentmsg = $('#comment').val(); $.post( "user_submit.php", {comment: $("#comment").val(), aid: imgnum, uid:$("#uid").val()}, function(data){ /*alert(data);*/ //$('#greetings').html('Your choice was submit...

generate a 5 char long string 0-9 a-z

I need a function in php that can generate a 5 char long string with numbers and a-z What should I look into? ...

Run function in "background"

Hello, Objects: Object Sale n Object User will participate on Object Sale Each User can create one Object Agent Each Agent will generate n Object Licitation (from time to time and with some conditions) for the object Sale Goal: Create a function that when a Sale has only 5 seconds left to end, will check all the Agents that there a...

Sending emails with wamp

I use the latest WAMP and i get this when i try to send emails: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\main\createaccount.php on line 8 Message delivery failed... the message $to = "[email protected]"...

timeout in php, is there any other way than using sessions?

I want to redirect users from a certain page after 10 minutes, and as I redirect them I want to do some stuff with some php code. Is this possible without using sessions? What if the user clicks the 'stop' button on his/her browser? Thanks! ...