php

processing returned json array in jquery

I have a PHP page that returns a piece of HTML to set the values of a menu. while($employee = mysql_fetch_array($query)) { $employee_menu = $employee_menu . '<option value="'.$employee['id'].'">'.$employee['first'].' '.$employee['last'].'</option>'; } echo json_encode ($employee_menu); Then update it with jqu...

SQL Joining 2 similar tables

Hi, I have two tables which are used to store details of different types of events. The tables are almost identical, with fields such as date, duration etc. I'm trying to perform a join on the two tables and sort them by the mutual field 'date'. I know it would be simpler to simply add a 'type' field to a single table and store it all...

PHP ereg vs. preg

I have noticed in the PHP regex library there is a choice between ereg and preg. What is the difference? Is one faster than the other and if so, why isn't the slower one deprecated? Are there any situations where it is better to use one over the other? ...

Codeigniter form validation callback function not working

Hi I've written a simple callback function which isn't working. My other callbacks (which are in the same library file) work fine so I guess the problem has to do with my code. The parameter passed in the callback function takes the form of a chunk of PHP which is eval()'ed to form part of an 'if()' statement in the function itself. H...

PHP Variable from extended class

I'm trying to retrieve a variable from an extended class. This is how my main class looks: class SS { public $NONE = NULL; public $NUMBERS = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); public $OPERATORS = array("=", "&&", ">", "<", "+", "-", "/", "*", "^"); public $DBLQUOTES = '"$1"'; public $SNGQUOTES = "'$1'"; publi...

Revert escaped characters

I saved some data in the database using mysql_real_escape_string() so the single quotes are escaped like this &#39;. It looks ok in the browser, but how can I convert it back to single quote when I save the text in a txt file? ...

Get raw post data.

According to php manual nor php://input neither $HTTP_RAW_POST_DATA work with multipart/form-data POST-requests. "php://input allows you to read raw POST data. It is a less memory intensive alternative to $HTTP_RAW_POST_DATA and does not need any special php.ini directives. php://input is not available with enctype="multipart/form-data"...

How can I make custom Wordpress comments form?

I have made following form, but it doesn't work because it doesn't send post id in post request. <?php require('./wp-blog-header.php'); $post = get_post($_GET['p']); ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" > <label>Name : </label><br/> <input name="author" id="author" type="text"/><br/>...

Get characters after last / in url

Hi, I want to get the characters after the last / in an url like http://www.vimeo.com/1234567 How do I do with php? ...

how to send html mails using PEAR mail

Hi, I am using PEAR mail system to send authenticated mails.I need to send HTML mails that has alinks.It was working fine before i started using PEAR mail.Now i am not able to send HTML mails. mail body looks like this: $body = <<<EOD Hiya $username You might be interested in the current 'haves' and 'wants' on example.com Latest Ha...

PHP line breaks being messed up by GIT

Our website has one section which often changes to match the user. (examples are greatly simplified). user:Mike last visit:Yesterday The method used to update the content [which I cannot now change] is that php searches the html webpage for the default content, and replaces it with new content before serving it to the user. $stats = ...

PHP's dom->createTextNode escapes some characthers

I am using dom->createTextNode() in PHP. I see that it automatically escapes characters e.g \/"" etc. According to the PHP's manual this is a standard behavior. Is it possible that it doesn't escape any characters? Thanks. ...

How to remove text between tags in php?

Hiya, Despite using PHP for years, I've never really learnt how to use expressions to truncate strings properly... which is now biting me in the backside! Can anyone provide me with some help truncating this? I need to chop out the text portion from the url, turning <a href="link.html">text</a> into <a href="link.html"></a> Any ...

How to enable Socket in PHP

Hi all Could any one tell me how to enable SOCKET support in PHP Thanks Fero ...

PHP Pagination, MySQL LIMIT problem

As some of you may know, use of the LIMIT keyword in MySQL does not preclude it from reading the preceding records. For example: SELECT * FROM my_table LIMIT 10000, 20; Means that MySQL will still read the first 10000 records and throw them away before producing the 20 we are after. So, when paginating a large dataset, high page num...

Upload files using Google Gears and ASP.NET or PHP

Trying to upload files using Google Gears and ASP.NET... I assume you can as the HttpRequest API accepts blobs. I have FileUpload control in the page. <asp:FileUpload runat="server" ID="File1" /> Then the JavaScript var file1 = document.getElementById("<%# File1.ClientID %>"); var desktop = google.gears.factory.create('beta.desktop'...

using onChange for menu selection in jquery

My below code works fine and is used to populate a <select> item with dynamic <options> The problem is that say I end up with 3 <options> say: One / Two / Three and then I select the first <option> so that I can call jquery code to populate the next menu. One is already the <selected> item in the menu so it is not recognized as a onChan...

Change url-string

I want this url http://www.youtube.com/watch?v=dgNgODPIO0w&amp;feature=rec-HM-fresh+div to be transformed to: http://www.youtube.com/v/dgNgODPIO0w with php. ...

Point ob_start to a function inside a class to capture fatal errors

I'm trying to create a generic class in PHP that will provide a way to call a web service, parse the returning XML and return a JSON object. I ran into fatal errors on servers that do not support CURL and/or JSON and looked for a way to gracefully returning the error in a JSON object back to the client, rather than crashing.After some se...

How to fsockopen() [function.fsockopen]: unable to connect to 11.11.111.111:11

hi all could any one help me to solve this issue. fsockopen() [function.fsockopen]: unable to connect to 11.11.111.111:11(A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) Thanks in Advance Fero ...