php

Php not reporting any errors on IIS7

Hi, I am developing a PHP application using our XAMPP setup as a test server. Once the app is ready to deploy, I have to upload it to the client's server, The problem is the client's server is running IIS 7, and every time there is a PHP error it just displays a blank page... Now, my app has error_reporting(E_ALL) already set, and I d...

PHP 5.2.11 Update Problem

I just updated PHP 5.2.0 to 5.2.11 and now I am getting loads of errors when calling PHP :( I downloaded source and used the same ./configure line from old phpinfo then did make install. The errors I'm getting are below, anyone have any ideas how to sort out this mess please? This is on RHEL 5.2 PHP Warning: PHP Startup: dbase: Unab...

Access GET directly from JavaScript?

I suppose I could use PHP to access $_GET variables from JavaScript: <script> var to = $_GET['to']; var from = $_GET['from']; </script> <script src="realScript" type="text/javascript"></script> But perhaps it's even simpler. Is there a way to do it directly from JS? ...

is there a book on php for socket programming? or a general programming language?

i already have some experience with java and a bit with c/c++, i'd like to learn php now. i want to make some applications with sockets, which i already understand a bit of. however, it seems most books focus on php for web development, whereas i'm more interested in it as a general purpose programming language. am i "doing it wrong" or...

Convert only certain xml characters to their HTML entities (&#nnn;)

I have a problem where I have some html like this <p>There is the unfinished business of Taiwan, eventual “reunification”...a communiqué committing</p> In that text string I would not want to change the < and > to & lt ; and ^ gt ; However I would want to convert the quotes around “reunification” and the é in communiqué. ...

Replacing text function in php

Hello, I want to clean up some parsed text such as \n the said \r\n\r\n\r\n I look in your eyes my dear\r\n\r\nI see green rolling Forests\r\n\r\nI see the far away Sky\r\n\r\nThey turn into the rain\r\n\r\n\r\nI see high soaring eagles... more\n So I want to get rid of the "\n", "\r\n", "\r\n\r\n", "\r\n\r\n\r\n", "\r\n\r\n\r\n\r\n" a...

How to check for a duplicate email address in PHP, considering Gmail ([email protected])

How can I check for duplicate email addresses in PHP, with the possibility of Gmail's automated labeler and punctuation in mind? For example, I want these addressed to be detected as duplicates: [email protected] [email protected] [email protected] [email protected] Despite what Daniel A. White...

PHP and Regex - storing a piece of the string for later use in replacement?

Not sure if the subject was clear, hard to describe, easy to show: I need to convert this: $text = 'Bunch of text %img_Green %img_Red and some more text here'; to this: $text = 'Bunch of text <img src="/assets/images/Green.gif" alt="Green" /> <img src="/assets/images/Red.gif" alt="Red" /> and some more text here'; Thanks in advan...

PHP Error output - Plesk 9.2 with IIS7 and FastCGI

Hi All, Where can I view PHP errors that are generated by a Plesk 9.2 website? I currently get a generic 500 error when I create a test PHP error: 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. I have, unsuccessfully, tried to activate error reporting in the Plesk g...

PHP POST with header() and Bad header problems

I've come across a dumbfounding issue with sending headers in PHP. I've spent about 45 minutes reading on SO and other sites and I can't come up with a legitimate reason for my problem. I need to send a POST request to another server and I'm using the PHP header() function to set the values. I have sample code below. $server = '...

Preferred way to copy JPG files from a remote server using PHP

Hello, I'm using PHP to copy JPGs from a remote server to my own server. Is it best to simply use the copy() function, or are the jpeg-specific functions better? For example: $copy = copy($remote_url, $dest_file); -OR- $img = imagecreatefromjpeg($remote_url); $copy = imagejpeg($img, $dest_file); imagedestroy($img); What would th...

How to automate/simplify this content submission scenario?

I'm trying to think a strategy to automate or simplify content submission. A submission is by default done through a form and counts as one entry (some text fields + a random number of file upload fields). Through a web interface, I can imagine this as a regular form. But how can I automate the process to simplify it? I don't have a pa...

Update to php5.3 breaks connecting to mysql db

I just updated php to 5.3 and can no longer connect to my remote mysql server. I get the following errors: mysqli_connect(): OK packet 6 bytes shorter than expected mysqli_connect(): (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using old authentication It seems this has to do with the new mysqlnd driver. Is there a way to force ...

How to tell if a timezone observes daylight saving at any time of the year?

In PHP, you can tell if a given date is during the Daylight Savings Time period by using something like this: $isDST = date("I", $myDate); // 1 or 0 The problem is that this only tells you whether that one point in time is in DST. Is there a reliable way to check whether DST is in effect at any time in that timezone? Edit to clarif...

PDO binding values for MySQL IN statement

Hi, I have an issue with PDO that I'd really like to get an answer for after being plagued by it for quite some time. Take this example: I am binding an array of ID's to a PDO statement for use in a MySQL IN statement. The array would be say: $values = array(1,2,3,4,5,6,7,8); The database-safe variable would be $products = implode('...

Remove large block of blank text in PHP

Hello I have a string in PHP $string = "...................blah blah blah.................." where the ......... are blank spaces (stackoverflow doesn't let me enter many blank spaces). How do I remove this block of blank spaces before and after the "blah blah blah" text? "blah blah blah" is parsed data that changes. Thank you. ...

Preg match text in php between html tags

Hello I would like to use preg_match in PHP to parse the "Desired text" out of the following from a html document <p class="review"> Desired text </p> Ordinarily I would use simple_html_dom for such things but on this occasion it cannot be used (the above element doesn't appear in every desired div tag so I'm forced to use this approa...

mysql date storage & query performance with php

I've got a database of historical records from WW2 and currently each recorded event's date is stored in one integer field as YYMMDDHHMM. This makes simple tasks like ORDER BY, or searching for all events within a certain time period extremely easy. However, if somebody wants all events that occurred on December 1st in any year of the wa...

unbindModel call in CakePhp. How does it work?

How does unbindModel happen in cake? $this->User->unbindModel(array('hasAndBelongsToMany' => array('Friend'))); I wrote this in the beginning of a function. But still it queries the 'Friend' model. There was a call to paginate() in the middle of the function. So I thought the paginator might be generating the queries. I did added an ...

Add row in one table for every nth entry in another table

Basically what I have is a system where users get rewarded for every 10 comments. So, in the db, one table captures the comments, and the other a reward for every 10th comment added. For instance, if a user has added 40 comments, they will have 4 rewards/4 rows in table 2. It sounds so simple to me, but I can't seem to figure it. Though...