Regex for alphanumeric
I've this PHP regular expression: $username = preg_replace('/[^a-z0-9]/i', '', $username); It allows only A-Z and 0-9. How can I allow ., - and _ as well? ...
I've this PHP regular expression: $username = preg_replace('/[^a-z0-9]/i', '', $username); It allows only A-Z and 0-9. How can I allow ., - and _ as well? ...
How can I store a date-range in solr? I need to store the start-date and the end-date. Lets say it is a villa which is for rent during a period (start and end). I must use two fields right? In the search the user may chose start-date and end-date, so when querying solr I think I could use something like: date:[$start TO $end] ...
Hi! I am running a function: @socket_recvfrom($this->socket, $buf, 8192, 0, $from, $port); but this returns an error saying: socket_recvfrom(): unable to recvfrom [0]: The operation completed successfully. Anyone who has an idèa about this? What does this mean? OS: Windows PHP: 5.3 Morten ...
I have this value from database: '2009-1-1 00:00:00', okay, let me paste my code: $fetch = mysql_fetch_assoc($result); $db_value = $fetch['date'];//'2009-1-1 00:00:00' $today = date('Y-m-d H:i:s'); // Todays date If I want to compare the two values, what should I do: if($db_value < $today){ // Do something } or method 2, conv...
hi all, i'm a newbie in programming and in php too and i was wondering if anyone can help me with my array problem. i have two set of array, example: $name = array("peter","peter","joe"); $cars = array("ford", "gmc", "mercy"); and i would like to merge them into a multidimensional array like this $merge = array(array($name[0], $...
Hey I have the following code that should strip all non alphanumerics (excluding hyphens) from some text. It does however miss square brackets somehow? ereg_replace('[^A-z0-9-]', '', strtolower(str_replace(' ','-',$title))) Can anyone advise? ...
Sometimes, while coding in PHP we get parse or syntax errors like those: Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in /var/www/example/index.php on line 4 I would like to know, if there is a list of all possible errors that PHP interpreter can output. I've searched php.net, but couldn't find such thing. I need...
In my form I am asking for someone to upload a PDF file & an image. They are both being sent to the same array $_FILES['rfiles'] array. I want to validate $_FILES['rfiles']['type'][0] to "application/pdf" or "text/plain" specifically, and $_FILES['rfiles']['type'][1] to an "image/*" This first part is the working part of the code. I'...
hello, is there a way to convert this into javascript? <?php $url = 'http://www.yourdomain.com/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; ?> ...
Hello :) I have a height dropdown, but its missing '10, '11, '12, inches from the foot due to php going straight up a number once it hits .10, which it should. I figured maybe an if statement around the values area that detects the decimal being .9 and then automatically adding .10, .11, .12. However I wondered if anyone had anything n...
How can I post data using Jquery from selected data to the PHP? HTML code: <select id="test" title="test" class="test"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 </select> Jquery: $('.18').click(function(event) { var test_s = $('#test').val(); $('.opc_mfont').l...
Hello! I am writing some accommodation web-site.I am using PayPal as billing system.Before I redirect the client to the PayPal page I need to insert all relevant data to the MySql database. My question is:how do I fire the php( from the javaScript) without waiting to it´s replay?( and that the fact that the page that fire the php wil...
Hello, I have cafeid=(1,2,3,4,5,6,7) and checkid= (1,3,5) How can I show the output only (2,4,6,7)? Thank you for your answers. ...
Here's my code, I don't know why the checkbox isnt updated when I try to update the mysql database. Only the input box are being updated. <tr> <td><font size="3"></td> <td></td> <input type='hidden' name="stats6" value="0"> <td><input name="stats6" type="checkbox" id="dep" value="<?php echo $row["STAT6"]; ?>" <?php echo $row["STAT6"]...
I'm trying to use (.+?) to isolate the words "I. NEED. ISOLATION" in the source below: <strong>Label:</strong></font></td> <td valign="top" width="82%"> <font face="Arial" size="2"> I. NEED. ISOLATION </font> </td> using (.+?), I could do this: $regex = '/stuff before(.+?)stuff after/'; and for this html, that would be...
I'm developing a web app with zend framework and i'd like to discuss what is the best way to intergrate all the JS and FBML in a ZF project, anyone have some experience. For example, which may be a good solution for have the Facebook istante in every controllers, a front controller plugin? ...
Why can't the data in mysql not updated when I use checkbox, I already tried removing the input type hidden, but still didn't work. I think the problem must be in this part, because when I try to add records and check all of the checkboxes. Then I will try to update it. By removing the checks in the other entry. The data is updated. the...
Hi I'm building a Twitter search application in Flash and have encountered a security error when retrieving a user's information using the following... http://api.twitter.com/1/users/show.xml?screen_name= I noticed a crossdomain.xml file returned with the above. This works http://search.twitter.com/search.atom? Can anyone suggest a ...
I need to load an XML source using Simple XML, duplicate an existing node with all his children, then customize an attribute of this new node before rendering XML. Any suggestion? ...
Why cant i set $_SERVER['DOCUMENT_ROOT'] as attribute? see example code class foo { private $path = $_SERVER['DOCUMENT_ROOT']; // generates error private $blah; public function __construct() { //code } public function setBla($bla) { $this->blah = $bla; } } ...