php

How many max constants can i define in PHP ?

My site is having around 100+ constants defined and this can potentially reach 200. I'm using define() for defining constant. Will this cause a performance hit ? How many max constants can i define in PHP ? ...

inserting large number of dates

How can I insert all dates in an year(or more) in a table using sql My dates table has following structure dates(date1 date); Suppose I want to insert dates between "2009-01-01" to "2010-12-31" inclusive. Is there any sql query for the above? ...

How to create a video uploaidng and playing website?

How to create a video uploaidng and playing website using php, mysql. any body can help me? ...

JavaScript and PHP filename coding conventions

Hi, I would like to know the popular ways of naming files in JavaScript and PHP development. I am working on a JS+PHP system, and I do not know how to name my files. Currently I do for JS: framework/ framework/widget/ framework/widget/TextField.js (Framework.widget.TextField()) Framework.js (Framework()) So, my folders are lowercase...

MySQL Conventions?

Hi There, I just moved my website to a new server (Shared to VPS) I expected errors, and the only error that is really puzzling me is this SQL statement. echo mysql_query("SELECT COUNT(*) FROM users_online_now") This returns nothing! And if I try the mysql_num_rows, it returns mysql_num_rows(): supplied argument is not a valid MyS...

How to plan my web based project before starting code ?

Me and my friend started working together as partners , we have decided to make Kick-as* website after website. We have the ideas written down like 100's of them (yes we are choosing best and easy among them first). My friend does the layout design and arranging things , and my part is coding and server management. The little problem ...

Should my if statement work, is it structured properly?

if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile)) && $_SERVER['REQUEST_URI'] != "login" || "thankyou" || "confirm") Should this code work, operators wise and syntax wise? ...

Mysql results into array (PHP)

How can i convert mysql results (from mysql_fetch_array) into such a form? $some = array( "comments" => array( array( "text" => "hi", "id" => "1" ), array( "text" => "hi", "id" => "2" ), array( "text" => "hi", "id" => "3" ), array( "text" => "hi", "id" => "4" ) ) ); while the db looks like:...

Snow Leopard - PHP 5.3.1 installed... but no PEAR?

I've been trying to do some PHP work on my snow leopard machine.. but I've found issues when I need to use PEAR packages (as symfony handles its php plugins with PEAR). I've found some references that state that snow leopard includes PEAR.. but how come I cant find it?! Could someone confirm this.. if if so, where is my pear? ...

unit, integration and system tests for PHP applications

Hi, We were given an assignment to develop a prototype for a customer community. It was suggested PHP as the programming language. (but we're not supposed to actually code it, just a prototype with documentation is required) I'm wondering what are the best practices/ tools used in Unit testing, Integration Testing and System testing for...

Check if URL is exists using PHP

Hello, I want to check if an URL exists using PHP. for eg. If someone enters www.adflkjweoifj123912873.com, I want to check if this domain has a website, or its live on the web. Thanks Jean ...

Is there a way that i can read from mysql binarylog file with php code and insert query statement in DB?

I want insert query statement in DB for LOG. Is there a way that i can read from mysql binarylog file with php code and insert query statement in DB? ...

Safe image uploading with PHP

I want my site to have a feature for users to upload images, but I want to do it safely. Namely, I want to strip the EXIF data and any malicious code that could be in their image. I was thinking of a way to do this involving direct manipulation of the file, but it struck me, would it make more sense to just convert the image they provide...

problem during data modification

here my code - if($pin == '105') { $sqltree = "INSERT INTO tbltree (`userId`, `level`, `superId`, `rootId`, `childcount`) VALUES ('$child1', '1', '$newid', '$myroot', '0');"; mysql_query($sqltree); update_level($newid); } function update_level() { //for 1st level $newid = $_S...

PHP - How to convert the YouTube URL with Regex

How can convert the below youtube urls $url1 = http://www.youtube.com/watch?v=136pEZcb1Y0&amp;feature=fvhl $url2 = http://www.youtube.com/watch?feature=fvhl&amp;v=136pEZcb1Y0 into $url_embedded = http://www.youtube.com/v/136pEZcb1Y0 using Regular Expressions? ...

Best way to store and deliver files on a CMS

Hi all.. First of all, this isn't another question about storing images on DB vs file system. I'm already storing the images on the file system. I'm just struggling to find a better way to show them to all my users. I' currently using this system. I generate a random filename using md5(uniqueid()), the problem that I'm facing, is that ...

Order by text and then by number

I have data like: Audio 1 Test File 10 Audio 2 Audio 3 File 11 Audio 1 Audio 13 Audio 22 File 20 Test Test File 22 Audio 10 File 1 File 2 I need it order first by the text (i.e. Audio, File, Test) and then by number (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 etc.) The problem is that sorti...

PHP Beginner: How to pass PHP variable from one PHP code segment to another ?

I have index.php which uploads a file to server and sets several PHP variables (like $target_folder_and_file_name). index.php also has the following line (it was originally index.html): <script language="JavaScript" src="main.js.php"></script> After index.php returned to the browser, the browsers asks for main.js.php from the server ...

Imitate Google suggest with AJAX and PHP

I want to imitate Google suggest with the following code, which means: step 1: When user types in search box, the query string will be processed by a server php file and query suggestion string is returned(using Ajax object). step 2:When user clicks on a query suggestion, it will fill into the search box (autocomplete). Step 1 is a...

Codeigniter AOP

I need a good implementation of AOP paradigm for Codeigniter PHP Framework. What do you suggest me? ...