php

How to get the absolute url of <img /> in PHP?

The src of the <img> is known,as well as the url of the target webpage,like http://test.com/directory/hi.html,how to implement the general function to retrieve the absolute url of the image? ...

list images in a directory with php and add a specific class

How can i list images in a folder...(which could be any number) and echo them in a list making the sure the first li has a class of "first" and the the last list item has a class of "last" like so... <li class="first"><img src="flowing-rock.jpg" /></li> <li><img src="stones.jpg" alt="Stones" /></li> <li><img src="grass-blades.jpg" /></l...

Sending correct file size with PHP download script

I created a file download script in PHP, it works, but web browsers report the file as "Unknown Length". My code is as follows: function downloadFile($file){ // Set up the download system... header('Content-Description: File Transfer'); header('Content-Type: '.mime_content_type($file)); header('Content-Disposition: attachment; ...

Designing Libraries in CodeIgniter

I am about to start writing my first big CodeIgniter application, but before I get started I was wondering what the role of libraries should be. I'm a newbie to MVC, but from what I gather the model should be where the data structures are stored (business logic). So is the library a place to write application logic, in addition to contro...

rawurldecode and regexp for splitting words with and without quotes in javascript?

so here is the case: i have a string in php (containts 2 words): windows "mac os" i encode it with rawurlencode and put it in the URL after ?name= in an anchor. when i click it i see the following in the browsers url. index.php?name=windows%20%5C%22mac%20os%5C%22 and then i get it with javascript with jquery bbq. var string = $.de...

MYSQL / PHP - Efficient method for attaching users to a project

I'm building a system that has a user table and a project table. I'm trying to determine the most efficient way to connect users to a project. I'm was thinking about a table that records the relationship, but I wasn't sure if a serialized list in one field would work just as well. ...

Cannot get PHP cron script to run

I have a PHP script that I need to run every minute. I have made sure that the script works from the command line, and I'm using absolute paths to avoid any environment issues: /usr/bin/php -q /var/www/myapp/services/myservice.php Manually running that as root from the command line works fine, as I can see from the log file that my sc...

Generate random date between two dates using php

I am coding an application where i need to assign random date between two fixed timestamps how i can achieve this using php i've searched first but only found the answer for Java not php for example : $string = randomdate(1262055681,1262055681); ...

(php) - helping writing a script for uploading images

I am trying to upload an image to a directory on a server. i'm using the tutorial found at http://www.reconn.us/content/view/30/51/. First, is that a good method for uploading images using PHP? Second, I'm also going to store the info in a MySQL database. What is a good way to deal with images that have the same name that the user upl...

Can facebook connect have a profile canvas too?

I am working with facebook connect. In facebook app settings, for my connect site app there is an option to allow users to add the app as a tab on there user profile. When you click the tab on a user profile for my app, it loads nothing on the canvas because I have nothing set. So I am wanting to know, since I am just using it for con...

Magento Help -> Having difficulty FILTERING new products.

I'm having a little dilemma. The following code correctly displays the assigned products while ignoring the minimal pricing. The "as low as" option. <?php $cat_id = 123; // category id $category = Mage::getModel('catalog/category')->load($cat_id); $todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL...

What are some strategies to facilitate relatively heavy modification of vendor's code while preserving upgradability?

I am the lead developer on a project whose continuing mission is the implementation, expansion, and maintenance of our highly trafficked site's content management system. The CMS is neither an in-house solution nor an open-source project - it is an expensive product purchased from a vendor. Unfortunately, it's a very... shall we say......

whmcs emails problem

I am testing out the order process for a test webhost package I have already setup in whmcs. I have it set to automatically setup product upon first payment. When the order goes completes whmcs sends out only four emails to the new customer: "Order Confirmation", "Customer Invoice", "Invoice Payment Confirmation" and "Welcome". It does n...

Embedding PHP in XML

I am trying to execute PHP code in XML Below is the code is there better way of executing as we are using eval and far as I know it degrade the performance 80-85% as it is supposed to be used by browser. function processing_instruction($inParser, $inTarget, $inCode) { if ($inTarget === 'php') { eval($inCode); } } ...

adding hasMany association couse find() not to work well

OK, I am little bit lost... I am pretty new to PHP, and i am trying to use CakePHP for my web-site. my DB is composed of two tables: users with user_id, name columns copies with copy_id, copy_name, user_id (as foreign key to users) columns. and I have the matching CakePHP elements: User and Copy as a model UserController as con...

need help modifying "stock" php/mysql dreamweaver code

i am using the dreamweaver cs4 "insert into" function to manage multiple forms on a single page. but i am having difficulty editing the code so that it: inserts data from the form into the table retrieves the id of the newly added row echoes a confirmation message on the same page and a link containing the id (as a reference) here i...

Simple AJAX code not being recognized

Hi, I'm trying to begin learning AJAX, and I've already hit a little stump. So I'm starting simple and just trying to get an alert to pop up showing the length of the string the user types into a text field. The HTML: <form action="/scripts/addemail_fb.php" method="post"> <input type="text" name="email" value="Enter your email here!" /...

How do I insert a $variable into jQuery

I'm working in Drupal with jQuery. How do I insert a php $variable into a tag. $(document).ready(function(){ $("#comment-delete-<?php print $variable ?>").click(function(){ $("div.comment-<?php print $variable ?> span.body").replaceWith("new text"); }); }) or $(document).ready(function(){ $("#comment-delete-". $va...

Can I call a Model from a View?

Rather than use a full-blown PHP MVC, I'm designing one that will best-fit my uses. I have the basic framework done, and have coded the models and controllers I'll need to run my website. Now I'm moving onto the Views, and I've encountered a small dilemma. My approach is working fine for me, but for future reference, I want to know if w...

How to specify the parent query field from within a subquery in mySQL?

Is there a way to specify the parent query field from within a subquery in mySQL? For Example: I have written a basic Bulletin Board type program in PHP. In the database each post contains: id(PK) and parent_id(the id of the parent post). If the post is itself a parent, then its parent_id is set to 0. I am trying to write a mySQL que...