php

will PHP header() & exit() securely terminate a script before redirecting?

Is the following a secure way of protecting a user only area? if(!isset($_SESSION['username'])){redirect(SITE_ROOT . 'st_pages/login/');} using: function redirect($url) { header('Location: ' . $url); exit('<a href="' . $url . '">Redirecting you to: ' . $url . '</a>'); } ...

Using PHP to place database rows into an array?

I was just wondering how i would be able to code perform an SQL query and then place each row into a new array, for example, lets say a table looked like the following: $people= mysql_query("SELECT * FROM friends") Output: | ID | Name | Age | --1----tom----32 --2----dan----22 --3----pat----52 --4----nik----32 --5...

singleton factory connection pdo

Hey guys I am having a lot of trouble trying to understand this and I was just wondering if someone could help me with some questions. I found some code that is supposed to create a connection with pdo. The problem I was having was having my connection defined within functions. Someone suggested globals but then pointed to a 'better' sol...

Online booking system with php

Im looking for any tutorial for online booking and reservation using php and mysql. I cant find so much from google. ...

output all data from db to a php page

Hi, I'm a real beginner with PHP & mysql. Just for studying and for a simple example at school I would like to work this simple query and possibly output all the rows (or maybe even one) to a very basic output on a php page: <?php $user= "root"; $host="localhost"; $password=""; $database = "PetCatalog"; $cxn = mysqli_connect($host,$user...

How to lookup data based on the next sunday of the week

I need to lookup a row of data from MySQL based on the next Sunday of the week. Anyone know how? ...

Display database fields using first,1,2,..., last

Hello, Im trying to figure out how to achieve this: http://t-webdesign.co.uk/projects/geusa/industry_jobs.html Evenutually there will be lots of job postings under different industries, what would be the best way of implementing the 'page' links so i can display just 7 or 8 jobs at a time? Thank you ...

PHP something faster than explode to get filename from URL

My URL's can be absolute or relative: $rel = "date/album/001.jpg"; $abs = "http://www.site.com/date/album/image.jpg"; function getFilename($url) { $imgName = explode("/", $url); $imgName = $imgName[count($imgName) - 1]; echo $imgName; } There must be a faster way to do this right? Maybe a reg expression? But that's Chines...

PHP: Check if it has been one week since timestamp

Hi guys, Let's assume: $time = '2010-05-17 02:49:30' // (retrieved from MySQL TIMESTAMP field) How do I do the following in PHP: 1) Check if it has been more than one week since this time has passed? 2) Assuming "false" on (1), find out how much more time until the one week mark, rounded to days and hours remaining. I know this is...

Posting XML via curl (command-line) without using key/value pairs

Consider a PHP script that outputs all POST data, as follows: <?php var_dump($_POST); ?> The script is located at http://example.com/foo.php. Now, I want to post XML data to it (without using key/value pairs) using command line curl. I have tried many variations of the following: curl -H "Content-type: text/xml; charset=utf-8" --dat...

CURL request incomplete, suspect timeout but not sure.

I am currently using CURL via a php script running as daily cron to export product data in csv format from a site's admin area. The normal way of exporting data will be to go to the Export page in a browser, and set the configuration, then click on "export data" button. But as the number of products I am exporting is very large, and it...

calculated column or stored procedure or just php function needed ?

I have an order table in MySQL database, having a field/column which stores the date timestamp of when the order was placed. I need to calculate when the order must be shipped. I could probably figure out how to write a function to calculate the ship date and call that when ever needed but I think, not sure it may make more sense to ha...

PHPTAL Nested Repeat

Hello guys, I am having an problem trying to achieve a nested repeat in PHPTAL: <tr tal:repeat="business analysis_result"> <td>${business/trading_name}</td> <tal:block tal:repeat="selected_key selected_keys"> <td>HOW??????</td> <---problem </tal:block> </tr> basically I want to have the of inne...

PHP/Apache: Permission settings for uploaded JPEG image files not correct.

I just setup a LAMP development server and am still trouble-shooting some things. The server is installed on one computer and I use a Windows laptop to write my code and test the site via the web browser. My file uploading script works in that JPEG image files are successfully uploaded to the server, but when I try to view the images in...

CodeIgniter and SimpleTest -- How to make my first test?

I'm used to web development using LAMP, PHP5, MySQL plus NetBeans with Xdebug. Now I want to improve my development, by learning how to use (A) proper testing and (B) a framework. So I have set up CodeIgniter, SimpleTest and the easy Xdebug add-in for Firefox. This is great fun because maroonbytes provided me with clear instructions a...

How to display multiple categories and products underneath each category?

Generally there is a category menu and each menu links to a category page where shows all the items under that category. Now I need to show all the categories and items underneath with PHP/MySQL in the same page. So it will be like this. Category 1 description of category 1 item 1 (some details, such as name, thumbnail etc for each it...

MVC: Nested Views, and Controllers (for a website)

I'm about to do a PHP website using the MVC pattern. I am not using a framework as the site is fairly simple and I feel that this will give me a good opportunity to learn about the pattern directly. I have a couple questions. Question 1: How should I organize my views? I'm thinking of having a Page view which will have the header and fo...

What's a solid but basic search algorithm for php?

I am working on a project that involves searching for videos, these videos are tagged similar to how questions are tagged on stack overflow. I was wondering if anyone knows of a good 'tag-based' search algorithm. Thanks! ...

Test a database conection without codeigniter throwing a fit, can it be done?

I'm just about finished my first release of automailer, a program I've been working on for a while now. I've just got to finish writing the installer. Its job is to rewrite the codigniter configs from templates. I've got the read/write stuff working, but I'd like to be able to test the server credentials given by the user without codingi...

How to test jQuery Ajax with php?

I tried to just send some information to a php file using Jquery Ajax. I wanted to send some info to the php file every time a click is made. <script> $(document).ready(function() { $('#checkbox').click(function() { $.ajax({type : "POST", url : "test.php", data : "ffs=somedata&ffs2=somedata2",...