php

How are these 2 lines of PHP different?

Assuming we have a salt that's in the database and that has been generated like this $salt = time(); What is the difference between these 2 lines. $pass1 = hash('sha1', $password . $salt); $pass2 = hash_hmac('sha1', $password, $salt); They don't produce the same output. The first one, the hash function takes 2 params, while the h...

Joomla, Mysql error

I have uploaded a page with the code below to my joomla root directory. <?php $value = trim($_POST['opts']); if ($value){ $db = "my_db"; $link = mysql_connect('localhost',$me,$my_password); if(!$link) die("Error 1 ".mysql_error()); mysql_select_db($db); **$query = "SELECT introtext,fulltext FROM jos_content WHERE title='$value' "...

Getting the Percentage of changes

How can i get the percentage of the changes which happened? Like 1. date 1343360810 objectId 1628 field 10 value 3 1. date 1242360811 objectId 1628 field 10 value 5 1. date 1243364812 objectId 1628 field 10 value 5 1. date 1240360814 objectId 1628 field 10 value 5 This would mean the v...

PHP Regexp: Subpattern that might occur more than once

Hey there, I'm trying to write a regular expression for a code like this: <tr> <td>I'm some text</td> <td>1234</td> <td>1231</td> </tr> <tr> <td>I'm some text</td> <td>1234</td> <td>1231</td> <td>7181</td> </tr> (I know, bad html code... ) Now I want an expression that looks for every table row and can han...

remove key from associative array with single key

I have the following array, $myarray[0]['first_name'] $myarray[0]['last_name'] I want to turn it into: $myarray['first_name'] $myarray['last_name'] with a simple oneliner? ...

PHP Smarty - Get a list of all the variables in a template?

I'm using Smarty and PHP. If I have a template (either as a file or as a string), is there some way to get smarty to parse that file/string and return an array with all the smarty variables in that template? e.g.: I want something like this: $mystring = "Hello {$name}. How are you on this fine {$dayofweek} morning"; $vars = $smarty->ma...

PHP DomDocument Save XML with HTML

Hi, How would I save an XML file opened with DomDocument so that the HTML inside won't be encoded into HTML entities? ...

Output Excel file in PHP after echo

HI, I am trying to display results from a database in results.php. In the same file, after all the data has been displayed in the current webpage,I am placing a button to create a file based on this results to produce a Excel file. I am not sure how to do this. I have tried but it says you have to force excel file download before any ...

Creating a new Pdf by Merging Pdf documents using TCPDF [php]

How can I create a new document using other pdfs that I'm generating? I have methods to create some documents, and I want to merge them all in a big pdf, how can I do that with TCPDF? I do not want to use other libs. ...

PHP - Number of times downloaded

How can I display a counter that counts the number of times a file is downloaded? I've seen it before. "Downloaded 450 times". Thanks. ...

basic in smarty

I m somewhat okay with why & where Smarty is used and also the upper hand it has over traditional PHP... but please tell me how is the separation of the application and the presentation parts needed as the definition itself says this about Smarty.. Please suggest some web sites where i can get some details in simple literature....... ...

get php output from asp.net mvc

good day we are working on mvc webpage using c# and we are on the making of a getting php output to display on a mvc webpage. we have 1 page created in php with the filename "hello.php" and it displays "hello word" we have place the code for calling the page in a usercontrol, but when place it in the site.master ad run it gives us the...

mysql_connect connection lifetime

What happes when the scrip that made @mysql_connect($server, $user, $password) dies? How long does it live? Thank you! ...

basics in smarty for beginers

do Smarty and PHP go hand in hand.....and are these not two separate things...please tell me whats the main concept behind the separation of the application (the codings) and the presentation (the looks which includes the HTML tags) parts in Smarty ...

How to write a search query for this form

I want to write a search query that search on the criteria like city, rent, area. i am new to database and sql queries. How to write query. Please help. Any suggestions will be highly appreciated. My form snapshot is here ->> ...

Is it possible to learn Zend framework without learning PHP first?

Hi, this is maybe a silly question but I am really wondering if it is possible to use a MVC framework such as Zend without learning the language first? Thank you for your help! ...

Why is my AJAX Form Not Sending Email?

I am using a PHP Mail form with AJAX and it's not sending any mail. What am I missing here? send.php <?php error_reporting(E_NOTICE); function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } if($_POST['first_name']!='' ...

Drupal views - how to remove string pattern using "Rewrite the output of this field"?

Views - Fields: I want to remove a certain matching word from a returned string by using the "Rewrite the output of this field". Is there extended syntax for this or is there a way to use php string-functions/regex in this field? ...

Finding *two* html tags with Regular Expressions

Hello, I need to pull out the content out of two paragraph tags and break it with a <br /> tag. The input is like so <p> Yay </p> <p> StackOverFlow </p> It needs to be like <p> Yay <br /> StackOverflow </p> What I have so far is <p><?php preg_match('/<p>(.*)<\/p>/', $content, $match); echo($match[1])."..."; ?></p> Which pulls the ...

PDO Connection Class, please help me understand if I have this right.

Hi everyone, I've been playing around with PDO for the last few days, I'm working on a small CMS system to teach myself OOP skills, but even though it's only a small CMS, I want it to be able to handle whatever the web can throw at it. This is what I've come up with so far, I'm going to add connection pooling to the constructor to enab...