php

PHP - getting a site's favicon and converting it to png if necessary

Hi For any given site "example.domain.tld" or merely "domain.tld" I need to do the following in PHP: If the site has a favicon, get it wherever it is If it is not already a PNG, convert it to PNG Save it to /favicons/example.domain.tld.png If the site has no favicon, do nothing. Any ideas? I'm being stumped by the unreliable filef...

Why does this PHP regex give me error?

Need Some Help With Regex: I want to replace [url=http://youtube.com]YouTube.com[/url] with <a href="http://youtube.com"&gt;YouTube.com&lt;/a&gt; the regex preg_replace("/[url=(.*?)](.*?)[/url]/is", '<a href="$1">$2</a>', $text); why does this give me: Warning: preg_replace() [function.preg-replace]: Unknown modifier 'r' in C...

MYSQL SELECT DISTINCT is not distinct in the PHP, but is distinct in the database

Hiya, I have another problem with sql queries running as I expect in PHPMyadmin, but when I add the sql to my PHP script, it does not work as expected. This is the formula of my sql: select DISTINCT table1.id AS ID, table1.title AS Title, table1.startdate AS StartDate, table1.enddate AS EndDate, ...

PHP syntax question: What does the question mark and colon mean?

Possible Duplicate: quick php syntax question return $add_review ? FALSE : $arg; What do question mark and colon mean? Thanks ...

mysql_num_rows error

I have problem with mysql_num_rows() function. I've checked query (it has proper syntax and I'm getting the result in sql) and connection to database and everything seems to be able to work. // some code here, connecting to database and working query to db $query = "SELECT ff_client.email FROM ff_order, ff_client WHERE ff_order.id = '$o...

Transparent gif/black background?

I have the following, it works except the gif is suppose to be transparent and it is creating a black background, if I change all the (imagesavealpha, etc) stuff to the $container then it created a transparent background for the text I add to this image. How would I go about getting rid of the black background? Basically this is a signat...

Remove line breaks from between html tags.

I'm making a form (html & php) which is part of an admin section used to edit content for a website. I want to allow users to include some basic html. This works fine. I want to retain line breaks. This also works. My problem is that when someone writes something like this: <ul> <li>item one</li> <li>item two</li> </ul> the line break...

jQuery AJAX live update on multiple elements on the same page

I'm delving into some AJAX and I'm trying to utilise jQuery. I have an index page which links to multiple pages and next to each page is a view count. I would like the view count to refresh and automatically update every couple of seconds so that those on the page can view live updates of the page counts. I've come accross the followi...

Need to display all the Countries List in ASC order With a line break at end of Every Alphabets

Hello all, I am in need to display all the Countries List in ASC order. But with a line inbetween every end of alphabets. This is by using PHP and SMARTY Example: America Australia Belgium India Like the above i need to display the O/P. My query is $str = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,Y,Z'; $let=explode(',',...

Upload sets of images to one single folder or seperate folders for each set?

I would be having 150-200 products on my website which could grow in the future and I have around 30 - 40 images for each product so I wanted to ask should I have separate folders for storing images of each product or save all the images in one single folder? Thanks ...

What is wrong with my syntax here?

The goal is to count the number of paragraphs in a group of users text... (I will assume its always bigger than 5 paragraphs for this exercise) Then I want to 1/2 the number of paragraphs, round it down and enter some content(echo "yehhoo") in between. I do understand the way I have gotten my $newvalue is not very good, would also lik...

RegEx problem - retrieve content of tag with given class - preg_match(_all)

Hi, I need to retrieve content of <p> tag with given class. Class could be simplecomment or comment ... So I wrote the following code preg_match("|(<p class=\"(simple)?comment(.*)?\">)(.*)<\/p>|ism", $fcon, $desc); Unfortunately, it returns nothing. However if I remove tag-ending part (<\/p>) it works somehow, returing the string wh...

Looking for real world examples of bitwise operations in PHP

Hey guys! I've been looking at bitwise operations as a way of speeding things up in critical areas. But most of what I find are just low level explanations. Would anyone be so kind as to briefly explain what practical situations i may find myself needing bitwise operations? Or perhaps a link to a good tutorial? Thanks! ...

Drupal - logic of the template.php file

Hi guys, I have spent a good proportion of time today looking into expanding a drupal site I inherited, convinced that the issues I face were down to my bespoke SQL query. I have since realised that the SQL is ok (checked it in PHPMYadmin and got it executing of sorts within the drupal website). So I am happy I am getting all the resul...

MySQL Result Array in PHP

Let's say I have this query in PHP. $a = mysql_query("SELECT * FROM `users` WHERE `id` = '1' "); Which is nice and all, but I have a problem. How do I view the contents of $a, which I presume is an array like so: Index | Value ID | 1 Username | Foo Password | Bar ... ...

Extremely basic PHP and Mysql

Background: I am more of a designer than a programmer, but have hacked templates for many open source CMS's (Drupal, Joomla, Wordpress) I want to start from scratch in regards to the relations of php and a mysql database. Lets assume I have a working database and php engine locally. What would be my first step to connecting to my data...

PHP MVC - how to pass data between different layers - objects or arrays

I always come to the same problem when implementing new data object that some web site will use. It seem to me naturaly to fill the object ... object: news news subobjects: mediaItems, user, category I usualy implement lazy loading of associated objects (lists of objects) and also have a static method to fill the news object data, med...

Dynamic Website on static html

I am trying to create a script that will display the contents of a folder, onto a newsticker, and I was wondering if anyone had a script that could run this. I was thinking probably php, but it has no been working for me. Thanks for the help The software I am using is dreamweaver cs4 if ($handle = opendir('$dir_path')) { while (fal...

generate weekly calendar in mysql/php

i'm developing a read-only weekly calendar view of users's events. Columns are the days of the week (mon > sun) Rows are timeslots (8:00>9:00, 9:00>10:00... from 8AM up to 7PM) Question: what's the best approach to generate that user calendar: Option 1: pure SQL I don't even know if that is possible, but i would find it supremelly eleg...

CodeIgniter Error

Hi, I am currently developing a site with codeigniter that uses paypal standard payments. When a payment is made paypal sends the information back to the site using an IPN notification and returns the user to the site along with the info as a PDT. I use both because I am giving digital downloads. Both PDT and IPN verify that the inform...