php

Is there a way to limit number of submissions for a php form?

eg. A registration form can only be used x amount of times? ...

oops - a ghost tab-box in firefox

I was happy to cobble some code together that gives me a nice looking tabbed-box on my (wordpress) page - 2 tabs; a feed and recent comments. Only after a few days have I noticed a problem: Firefox shows 2 tab boxes, one below the other, each showing the other tab. IExplorer displays a single functional tab-box as intended. Could some...

Order by date in mysql

I want to sort my result form mysql by date. I use the query like this: <?php $date = $db->get_query("select distinct created_date from comments"); $condate = ''; for($i=0; $i < count($date); $i++) { $condate = $date[$i]['created_date']; $data = $db->get_query("select id,created_date from comments where created_date='$condate' order...

include image in generated GD image

Is it possible to include an external image (gif, jpg or png) into a GD generated image? what I'm trying to do is get the latest wordpress blog post (like 5) and generate an image from it. I would like to include the title and the image uploaded with the blog post. ...

Should one use strict comparison in Strings?

I know that for instance, using: if (in_array('...'), array('.', '..', '...') === true) Over: if (in_array('...'), array('.', '..', '...') == true) Can increase performance and avoid some common mistakes (such as 1 == true), however I'm wondering if there is a reason to use strict comparisons on strings, such as: if ('...' === '.....

Best practices for (php/msql) deployment to shared hosting?

Hello there I have worked within a web development company where we had our local machines, a staging server and a a number of production servers. We worked on macs in perl and used svn to commit to stage, and perl scripts to load to production servers. Now I am working on my own project and would like to find good practices for web d...

What’s wrong with my HTTP redirect?

I’m using the following code to redirect the user if he/she logged in correctly (see comments in code). But I’m getting an error. What am I doing wrong? <?php require 'inc/header.php'; require 'inc/config.php'; require 'inc/functions.php'; ?> <? $login = $_POST['login']; if($login==1) { $username = mysql_escape_string(t...

MySQL query to order by parent then child places

I have a table of pages in my database, each page can have a parent as below: id parent_id title 1 0 Home 2 0 Sitemap 3 0 Products 4 3 Product 1 5 3 Product 2 6 ...

Cookies - PHP vs Javascript

With regards to security and convenience which cookies are better the PHP ones or the Javascript ones? ...

Sending $_SESSION variables with window.location redirect

My problem: I have few buttons in the page I'm modifying - they have onclick events: javascript:window.location.href='http://www.another.page.com/'; return false; I have to send $_SESSION variable to redirected page. I can't do it in previous page because the variable will be different for each button. How can I do it? ...

bulk insert mysql - can i use ignore clause? is there a limit to no. of records for bulk insert?

I have a bunch of data that i want to insert and i have decided to use bulk insert for mysql. insert into friends (requestor, buddy) values (value1, value2), (value2, value1), (value3, value4), (value4, value3), ... i would like to know the following: 1) can i use ignore? eg insert ignore into friends (requestor, buddy) values (value...

Quickest way to get total records from a mysql table in PHP

Below is the current code I use to get the total number of photos in a DB, An estimated number would even be acceptable as the number of results is just used to determine which folder number I would like to upload into for folder balance of files. I have a feeling there is a better way then I am using below? $sql = 'SELECT auto_id FROM...

Regex allows only 1 character

$rex = '/^[^<,"@?=>|;#]$/i'; I'm having trouble with this regular expression. The idea is that the input fields are checked for certain characters and if present, throw an error. This regex is throwing errors for every string longer than 1 character. Can anyone tell me what I'm doing wrong? EDIT: People are saying they don't see what...

Image upload works sporadically.

This is a very open question about a problem that we have. Basically, we have an image upload function on our site, built on Zend PHP that works great and smoothly almost all the time. Yet the logs show continuously that the entire framework crashes pretty much all the time and the image upload fails and I don't have the slightest idea ...

Embed JS that passes a variable to PHP to request more JS code

Hello all, I am trying to make use of Google's API as a way to get the location of the user. Once I have done this, I pass this to an external PHP script which will further output some JavaScript code. However, I am having trouble calling the PHP script: <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAKw7Q"&gt;...

What is this php supposed to do?

I found this code below in a script, I am trying to figure out if it is actually supposed to do more then I am seeing, As far as I can tell it results in an array of: $maxSize[0] with $new_width $maxSize[1] with $source_width $maxSize = array($new_width ? $new_width : $source_width, $new_height ? $new_height : $source_height); ...

What kind of file types does PHP getimagesize() return?

Does anyone know all the possible results for the 3rd value returned from PHP's getimagesize() function? Example this code below will return $imageinfo['2'] = 2; for a jpg image $imageinfo['2'] = 3; for a png image $imageinfo['2'] = 0; for a gif image the numbers might not be correct above but you get the idea. I can not find on ph...

Use the result of one Mysql command in Another Mysql Command??

Excuse my ignorance but I'm having a tough time figuring this out. I'm trying to take the result from one mysql command, and use it in another command. Here's my code, it doesnt work. //select the event end date of event ID $sql = "SELECT enddate FROM mm_eventlist_dates WHERE id = $id"; $result = mysql_query($sql); //plug in the eve...

Best method of moving an uploaded file in PHP?

I have a php script which uses this below when a user uploads a photo: if (is_uploaded_file($HTTP_POST_FILES['picture1']['tmp_name'])) { move_uploaded_file($HTTP_POST_FILES['picture1']['tmp_name'], $full_file_path); } I am curious, should I be using this instead? IF so, is there any benefits? if (is_uploaded_file($HTTP_POST_FILES...

uploadprogress_get_info and m4v files

Hi all, I'm having trouble getting uploadprogress_get_info and m4v files to play nicely together. Has anyone else had the same trouble? UPLOAD_IDENTIFIER is being sent with the file, it's just this one file type where it doesn't work. Any ideas where I can begin to start debugging? ...