php

simple question about preg_match() in php

hey guys i used bellow code to search and find if http is includes in $url address user enters if (!preg_match("/http:///", $user_website) but i got this error Warning: preg_match() [function.preg-match]: Unknown modifier '/' in i know its becuase of // of http but how work arround this !? ...

When (if ever) is eval NOT evil?

I've heard many places that PHP's eval function is often not the answer. In light of PHP 5.3's LSB and closures we're running out of reasons to depend on eval or create_function. Is there is any conceivable cases where eval is the best (only?) answer in PHP 5.3? This question is not about whether eval is evil in general, as it obviousl...

What exactly is the difference between the is_callable and function_exists in PHP ?

I am working on a project, in which i am using some deprecated function form the older version. But don't want my script to be stopped if used in the older version. So i am checking if the function exists and if it doesn't then creating it again. But what is the difference between function_exists and is_callable in php and which one is ...

mysql_fetch_object(): supplied argument is not a valid MySQL result resource

I'm trying to set a simple cron script to do some database updating, and I'm pretty worthless with MySQL without ActiveRecord (I use CodeIgniter). I keep getting the error message, mysql_fetch_object(): supplied argument is not a valid MySQL result resource with the following code: mysql_connect("localhost", "user", "pass") or die(...

How to pass an array of strings from PHP to Javascript using $.ajax() ?

I have a PHP script that retrieves names (strings) from database. I would like to pass this array to Javascript using $.ajax(). I cannot understand how should I encode the array in PHP and then decode it in Javascript. Could someone give an example code for this ? Thanks a lot !! ...

notifying the user about successful update in codeigniter

Hi Guys, i'm using these two lines to update my table using codeigninter active records $this->db->where('reference_number', $reference); $this->db->update('patient', $data); what i want to de is to check weather it successfully updates the table and according to that i want to give a notification to the user, how can i check the su...

Creating an advertisement system for your web sites (my own AdSense).

I do not know the right term for this but say I want to have Ads on my web sites where there advertisers need to pay whenever users click on the web sites. How should one go about doing this? My approach is to link the Ad to a script file that will record the click in a database and redirect the user to the advertiser's site. I see one...

How to highlight a link from a PHP generated nested list.

I have a PHP script that displays all my topics in nested list and I want to be able to click on a link and when doing so have it be highlighted but i don't know how to go about it with my current code, can someone help me with this? I'm using PHP, CSS and JQuery Here is my PHP code to display all my topics in nested lists. function m...

how to pass the result of custom query in pagination

hi i am using cakephp for my project but i have problem when i generate result from custom query. then i have no idea about that how to that result in to pagination. so please help me. thanks in advance. ...

Ajax response always coming up undefined

Here is my JavaScript code: $('check_username').addEvent('click', function(e) { var req = new Request({ url: 'Namecheck.php?name='+$('user_name').get('value'), method: 'post', onRequest: function() { alert('Namecheck.php?name='+$('user_name').get('value')); }, onComplete: function(response) { alert('The response is the...

Doctrine 2 PlainValue expected

I'm having trouble executing a Doctrine DQL Query. This is the error it gives me. Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue, got 'integer' at position 13 in property Base\Session::$lifetime. My code looks like this: $query = $em->createQuery("SELECT s FROM Base\Session s WHERE s.session = \"...

Strip letters in php

We have variable with text: $text = 'I use something similar to pull the most recent post from my blog and display a snapshot of it on my home page.'; How to strip first 40 symbols of this text? (including spaces). Should work like this: echo strip_text($text, 40); Thanks. ...

preg_replace not working for utf-8 Arabic text

I writing a php function to check existence of bad whole words (keep in mind whole word not sub-strings) and also highlight whole words in given string. function badwordChecherAndHighLighter($str,$replace){ // $replace=1 will Highlight // $replace=0 will Check the existence of any badwords $result = mysql_query("SELECT settings_ba...

error during addslashes() function in php

html form code- <td width="75"> <input name="txtQty[]" type="text" id="txtQty[]" size="5" value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);"> when I submit form I calls following script- if (!get_magic_quotes_gpc()) { if (isset($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = trim(add...

How to add up a row of values in an array and move to the previous key PHP

Hello, I would like the value that has an o in the following example to be added to the key before the first key that has a value with an o in the array. Like this: $arr = array( 0 => 'apple', 1 => 'pear', 2 => 'orange', 3 => 'octopus', 4 => 'pineapple' ) $arr = array( 0 => 'apple', 1 => 'pearorangeoctopus', 2 => 'Pineapple' ) But ...

Fatal error: Call to a member function create() on a non-object in <file>

Hi, For a php project I use a Collection class to handle my objects and lazyloading in Java-like collections. Now my object has a collection of emailaddresses for example. So I call the getEmailAddresses() function of the object which calls the mapper to return a collection of emailaddresses. This works fine, but when I do a foreach l...

MAIL NOT SHOWING UP

<?php $to = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); $send = mail($to, $subject, $message, $headers ); if ($send) $mailReturns = "Ma...

Doctrine: Bind IN parameters

I was wondering if it is possible to bind an array of integers as a parameter, so I could do something like this? $q = Doctrine_Query::create() ->update('blah c') ->set('ignored', true) ->where('id in ?', array(1,2,3,4)); I guess that this isn't possible because it actually b...

Is string base 64 encoded?

How can I find whether a string is a data encoded with base64_encode() function or not? Is it possible? ...

How to pass textbox value to another script on link click event.

I have a form like this: one.php <form id='myFormId' name='myFormName'> <input type='text' name='myTextField'> <a href='two.php'>Show Value</a> </form> Question: I want to pass 'myTextField' textbox value to two.php and want to echo it on screen. I can't use submit button and also can't submit the form. Is there any trick ? Tha...