php

How do you rewrite/recode a website to be scalable?

How do you rewrite a website to be scalable?(traffic) I work with mainly PHP and some Ruby on rails and i know its a generic question. I'm just looking to increase my knowledge so any advice would be useful. Thank you in advance ;-) ...

Your PHP MySQL library version differs from your MySQL server version

I've recently upgraded MySQL on my Debian 5.0.4 server to 5.1. Now phpMyAdmin shows the following warning: Your PHP MySQL library version 5.0.51a differs from your MySQL server version 5.1.43 Is it likely to cause any problems? ...

list and explode

Hey everyone, I am trying to use url rewriting on my website and I want to use the list() and explode() functions to get the right content. Currently my code looks like this: list($dir, $act) = explode('/',$url); In this case $url is equal to everything after the first slash in the absolute url i.e. http://example.com/random/stuff =>...

anti spamming in php

hey guys , today i visited my website and i saw someone insert more than 1000 query in my story table my script is in php/mysql and i have captcha enabled and i wonder how he can do such a thing a simple form and in another function , it checks $vars and validate them and then insert in database im sure he is using a bot to do ...

php & mySQL: Load only functions that are needed and only on demand while avoiding duplication

Hi all, I use the following procedure to call the functions within the pages of my web app. //index.php include("functions.php"); include("file1.php"); include("file2.php"); I have all my functions going into functions.php page. The content of this page may be over 5000+ lines of code and it contains all the functions used within the...

insert value at the begining of an array in php

my array is $hello= array( Code => 'TIR', Description => 'Tires', Price => 100 ) now i want to add a value in array begining of an array not the end of an array.... and results i want is $hello= array( ref=>'World', Code => 'TIR', Description => 'Tires', Price => 100 ) UPDATE actually i need any value that is coming will be added in...

Running PHP without extension without using mod_rewrite?

Using Apache 2.2 and PHP 5, what's the best way to run PHP without the .php extension. For example, I have a script called app.php and I like to invoke it as http://example.com/app Please notice that I still want keep the .php extension to the file and I don't have mod_rewrite. Don't want use index.php either because it requires too ma...

How do I store the results of this recursive function?

I have the following PHP code which works out the possible combinations from a set of arrays: function showCombinations($string, $traits, $i){ if($i >= count($traits)){ echo trim($string) . '<br>'; }else{ foreach($traits[$i] as $trait){ showCombinations("$string$trait", $traits, $i + 1); }...

How Server-Side Include Work without File Extension?

This question is related to this one, http://stackoverflow.com/questions/2358178/running-php-without-extension-without-using-mod-rewrite So by adding this to my .htaccess, I can run PHP script without the extension, AddHandler server-parsed .php SetHandler application/x-httpd-php AddHandler application/x-httpd-php .php I am not fami...

PHP Streaming MP3

I have a very similar situation to the person who asked: http://stackoverflow.com/questions/1516661/can-i-serve-mp3-files-with-php Basically I am trying to protect mp3 files from direct download, so users have to go through php to get authenticated first. Here's my code: header('Content-type: audio/mpeg'); header('Content-length: ' . fi...

Help find security flaws in this MySQL page?

I am trying to find security flaws in a MySQL page. It is an assignment for a class learning about SQL. Through a textbox, they will be given access to a database to submit queries and see if it returns the correct data sets. I want to find out if there's anything malicious they could do. This is the result of a SHOW GRANTS query: Gran...

PHP Regular Expression To Match Any URL Except Those From Example.com

Provide an example for the pseudo-regex: Match every url except those from example.com and example2.com according to the PHP regexp syntax. Here is what I have so far, but it doesn't work: $patternToMatch = "@https?://[^(example.com|example2.com)]\"*@i"; ...

Do I need to compile my php files?

Hi i'm used to programming with ASP.Net but i got just landed a project doing PHP development.. My question is this, in ASP.Net if you make changes in the code behind you have to recompile the app before uploading. Is it the same with PHP? I know it's not a compiled language but I want to know if I can make changes to the PHP code in a ...

In PHP5, how do I create a multidimensional array from a database query?

I am creating a class for an application "backbone" and I need this function to query the db, and return a multidimensional to look like this: $myArray = ("name"=>"John", "dob"=>"January 5, 1955"); Of course the data for the array is from a database query. but, "name" and "dob" would be the database column name and "John" and "Januar...

How to write to file in large php application(multiple questions)

What is the best way to write to files in a large php application. Lets say there are lots of writes needed per second. How is the best way to go about this. Could I just open the file and append the data. Or should i open, lock, write and unlock. What will happen of the file is worked on and other data needs to be written. Will this ...

The Checkbox opens link onClick when form is submitted, but how do I post the form at the same time?

I am trying to build a downloads section where the visitor completes a form and then selects check boxes to open download dialogs. I would like the form to submit and the dialogs to open, when the button is clicked. I am not very good at writing scripts, although I can read them. Currently I can only get one or the other to work! The ...

while() and onclick..

Hi. I have this: while( $rowData = @mysql_fetch_assoc($selectRows2) ) { ?> <div id="stemmeto"><a href="#" id="thelink" onclick="window.parent.OpenVote(<? echo $_GET['id']; ?>, '<? echo $rowData['username']; ?>');"> <?php echo $rowData['username']; ?> </a></div> <div id="stemme"> <a href="#" id="thelink" onclick="window.parent.O...

Debugging mysterious PHP requests

Whenever I get a 404 our logout script is being called mysteriously. What should be happening is our custom ErrorDocument defined in the root .htaccess file should be redirecting to a static HTML page, without any external logout actions being initiated. I'm using Zend Studio's debugger and at first everything goes as expected -- it se...

PHP session handling when the same client requests the same script multiple times at once

So here's my test setup: session_start(); if(!isset($_SESSION['bahhhh'])) $_SESSION['bahhhh'] = 0; $_SESSION['bahhhh']++; sleep(5); die('a'.$_SESSION['bahhhh']); What I expect to happen is that each time I hit the page, it returns a different number. But if I use multiple tabs, and refresh them each within 5 seconds of the first, ...

What is the best flexible means of comparing version numbers?

I am working with a script to compare version numbers for installed and available applications. I would, on a normal basis, use simple comparison operators. Since I am building this application in a PHP 5.3 environment, I have considered the use of version_compare(), but that doesn't seem to suit my needs as cleanly as I would like. The...