php

curl error 18 - transfer closed with outstanding read data remaining

Hello, when retrieving data from a URL using curl, I sometimes (in 80% of the cases) get error 18: transfer closed with outstanding read data remaining Part of the returned data is then missing. The weird thing is that this does never occur when the CURLOPT_RETURNTRANSFER is set to false, that is the curl_exec function doesn't return ...

Submit with checkbox? No javascript

Is there any way to submit a form when a user clicks on a checkbox? Think of a todo list. When the user clicks on the checkbox, it updates the todo entry in the database saying its done. Can this be done without using javascript? ...

What's the correct way to escape sql passed into SugarCRM's get_entry_list soap api call ?

By the looks of the SugarCRM soap api you just seem to pass raw SQL into the restriction part of the get_entry_list function call. Is there a way to escape the values being passed into the restriction correctly without knowing the target database the SugarCRM instance is running on ? For example if I have something like // connect to...

base64 encoded data mixed in with "random" hex

I get an input string with some data that's base64 encoded. Unfortunately, it gets random hexadecimal data (all lowercase) mixed it. It's fairly straightforward to sort out by hand because the hexadecimal data all seems to be in segments of 32 bytes. For example, I can format an example string like this: 6dd11d15c419ac219901f14bdd9...

Zend Search Lucene numerical range searches

Hi all, I am having difficulty determining my misunderstanding of how Zend Search Lucene indexes and searches integers in ranges. In the following example, I would expect the output to be 1, however it is always 2 (both results). Any hints would be much appreciated. <?php require_once 'Zend/Loader/Autoloader.php'; $loader = Zend_Load...

Php preg_match help

I am trying to find a php preg_match that can match test1 test2[...] but not test1 test2 [...] and return test2(...) as the output as $match. I tried preg_match('/^[a-zA-Z0-9][\[](.*)[\]]$/i',"test1 test2[...]", $matches); But it matches both cases and return the full sentence. Any help appreciated. ...

PHP-generated javascript and quote marks

I'm generating some javascript in my PHP code, and I need to assign some php variables to javascript variables. Unfortunately, sometimes my PHP variables contain quote marks. for instance: $foo = "'Dis here be a \"string\""; print "<script type='text/javascript'>var foo = '{$foo}';</script>"; will generate a javascript error because t...

Need to write at beginning of file with PHP

I'm making this program and I'm trying to find out how to write data to the beginning of a file rather than the end. "a"/append only writes to the end, how can I make it write to the beginning? Because "r+" does it but overwrites the previous data. $datab = fopen('database.txt', "r+"); Here is my whole file: <!DOCTYPE HTML PUBLIC "-/...

What is the best way to go about creating a page of stickies with savable and retrievable content?

I have had a look at sticky notes with php and jquery and jStickyNote, and while both seem to look pretty nifty they lack some elements I am after. I haven't been able to find a way to allow particular users to modify the stickies they create, nor have I found a good way to save their stickies into my database. I am, and would like to ke...

Is regex the right tool to find a line of HTML?

I have a PHP script that pulls some content off of a server, but the problem is that the line on which the content is changes every day, so I can't just pull a specific line. However, the content is contained within a div that has a unique id. Is it possible (and is it the best way) for regex to search for this unique id and then pass th...

ErrorDocument 404 Not Sending Referrer Information: PHP

I'm using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $_SERVER['HTTP_REFERER'] is empty I printed out all of my global variables and most contain the link to pageNotFound.php. How can I retrieve thi...

How to display an Image from a mysql blob.

I am trying to display an image from a MySQL blob field. I have tried a few different things and none of them seem to work. I have tried: header("Content-type: $type"); img src = $blobData; header("Content-type: $type"); echo($blobData); ...

call function in php, little help please...

Hi... How can I call a function like below: $display_table="<table><tr><td>FUNCTION_CALL_HERE();</td></tr></table>"; I have tried brackets and all, but the function wont get called... How should I make this work? (syntax problems I think) Thanks ...

PHP stylesheet print switcher problems?

I have this print style sheet switcher i created a long time ago and know it wont work for some reason, its suppose to switch to a print style sheet when the link is clicked and display the print dialog box. But know it will only display the dialog box in FireFox and not in any other browser and will not display the print style sheet at...

How To: Displayed image file name different than actual filename on server.

I would like to display an image but have the file name different than the actual file name on the server. ex) The user would see <img src="/img/photos/Awesome_Picture_By_John.jpg"> by looking at the source code but the actual file name would be /img/photos/12b7dch2.jpg any help is appreciated. Thx ...

Download multiple files as a zip folder using php

Hai guys, I want to make my user select any type of files listed and make them as a zip folder and download it... The files may be .doc,.jpeg,.ppt.... ...

How to add a new member variable in PHP?

I want to do something like: class Name{ function assign($name,$value){ } } Which is pretty much the same as assign in smarty $smarty->assign('name',$value); $smarty->display("index.html"); How to implement this? ...

To show custom message in Symfony forms?

Want to show a custom message in form's error list, if the two fields did not match. the from is as follows, 'old_password' =>'Old Password*', 'new_password' =>'New Password*', 'confirm_password' =>'Confirm Password*', I want that the old password should match the value from the database, the value in new ...

storing temp data for shoping cart

I am doing shopping cart for my website Storing purchase information in session Storing purchase information in table. Which is better solution? If I store it in table how and when will i delete the records in the table (i.e when not purchased by user but in table) ...

How to implement display like smarty in PHP?

$smarty->assign('name',$value); $smarty->display("index.html"); So that it automatically replaces $variables in index.html which saves a lot of echo? ...