php

How to test MySQL query speed, with less inconsistencies?

I need a simple way to test SQL queries for speed. I am not to worried about hardware differences, I basically need a relative number. This is what I've been doing with PHP (its fuzzy, but works): // CONNECT TO DB HERE $sub = new YomoSubscription(95,783); $t = microtime(TRUE); // contains the SQL db call i'm testing $fp = $sub->gen...

Format output of $SimpleXML->asXML();

Possible Duplicate: PHP simpleXML how to save the file in a formatted way? Edit Yes, this is a duplicate. Voted to close. - Eli Hi All, The title pretty much says it all. If I have something like (from the php site examples): $xmlstr = <<<XML <?xml version='1.0' standalone='yes'?> <movies></movies> XML; $sxe = new SimpleXML...

Building Breadcrumbs in MySQL

I have a table that defines the possible categories in my website - fields look something like this: - id - name - parentID The information is stored something like this: +-----+------+----------+ | id | name | parentID | +-----+------+----------+ | 1 | pets | 0 | +-----+------+----------+ | 2 | cats | 1 | ...

What is the tried and true way of counting the number of rows returned from PHP `mysql_query` function?

I know about mysql_num_rows ( resource $result ) but I have read somewhere that is it not 100% accurate. I have seen other alternatives that actually gets each row and run a counter but that sounds pretty inefficient. I am interested in seeing what others do to get an accurate and efficient count. ...

PHP-based CSV editor?

Does anyone know of an online CSV editor written in PHP that will allow a user to open, edit, and save a given CSV file? All I can find are CSV classes and nothing that can handle dynamic files, just predefined lengths etc. ...

Looking for a fast, compact, streamable, multi-language, strongly typed serialization format

I'm currently using JSON (compressed via gzip) in my Java project, in which I need to store a large number of objects (hundreds of millions) on disk. I have one JSON object per line, and disallow linebreaks within the JSON object. This way I can stream the data off disk line-by-line without having to read the entire file at once. It t...

How can I create a dynamic login in PHP?

Here's how it works: User makes a payment User receives a password Their user name will be their email A folder will be created for that user, which contains the files the user paid to have access to. My main problem is that the software needs to be protected, and the password will be dynamically created. So I'm wondering if I need t...

On PHP Error Apache gives 500 Error

Everytime I get an error in any of my PHP, my local Apache server gives me a 500 Internal Server error. I never seem to have problems with any of my CakePHP projects, but this is plain vanilla PHP and it is really slowing down progress having to guess at the error. ...

Https, Php secure login page?

Hi, I am new to php, I can do a simple login page, e.g create form, submit form, process and authenticate in a php page and so on. I read somewhere on the internet, and saw some big companies like banks, google and yahoo, their login form is in "https" not "http". So I try google what is "https" thing. Well, I could not say I fully unde...

textarea occasionally missing in $_POST but content_length always correct ?

A strange bug has popped up on a server running a fairly active site. Server: Apache/2.2.3 (CentOS) PHP: 5.2.6 eAccelerator 0.9.5.3 While using multipart forms, occasionally data sent from a textarea will be missing in the $_POST We know the data was sent because content_length shows a reasonable size over 1K All other input fiel...

Render the square wave form graph using PHP

I would like to render the square wave form of graph using the only values of zero and one on certain time intervals. I used fusion chart line graph to render the chart but when the values changes from zero to one the line goes very slanting but i would like to show it straight. For example check out the attached image it shows the s...

Taking the filename alone... in PHP

I am able to upload a zip file and compress it, now i need the filename alone... but when i try to reach the name i get along with zip. asas.text = "upload/" +fileRef.name + "/" +as.text; Also How can i point the current viewing URL before the upload path.. something if http://www.yahoo.com/upload/filename/ If the file is viewed from ...

diffrent string formating types in php

like %2$s %04d %01.2f %'#10s etc. can you give me some more commonly used combination? ...

Count value from list/menu in ajax

Hello folks.. How to count values of two drop down using ajax or php Example Form Base Price : $10 Color [drop-down] Size [drop-down] Base Price : $10 <select name="color"> <option>Blue</option> <option>White</option> </select> <select name="size"> <option>8</option> <option>10</option> </select> Calculation ...

How do I display posts excluding one category on blog home page?

I want my home page to display posts from all categories except one called "music". And I don't want the link to change. How can I hook into the "Front page" or "Posts page" results and filter out one category? I am assuming I must make some call to the Wordpress API. Thanks! ...

An interesting Encryption Problem

Hi Guys, I have an interesting encryption problem at hand. I do not know if it can be solved but here goes: A database is to contain sensitive user information. As such, the user information must be encrypted (two way encryption). The user has a login / password and these may be used in the two way encryption. Now, the encryption is to...

Capture stderr output from a proc_open() on windows

I'm invoking the proc_open() and I can't capture the output of the process written to the stderr: $curFolder = getcwd(); $procDescriptor = array( 2 => array( "pipe", "w" ) ); $cmd = "MyApp.exe -f optimization.csv"; $process = proc_open( $cmd, $procDescriptor, $pipes, $curFolder ); if( is_resource( $process ) == true ) { $procStatus ...

How to remove a piece of HTML tags in a HTML page using PHP

I have a situation. I read in a html page using php using this piece of code $body = file_get_contents('index.htm'); Now in the index.htm file is a piece of html code like below that I sometimes need to remove/depends on criteria, so sometimes it needs to be removed and other times not. <td><table><tr><td></td></tr></table></td> How ...

Adding support for i18n in PHP with gettext?

I've always heard about gettext - I know it's some sort of unix command to lookup a translation based on the string argument provided, and then produces a .pot file but can someone explain to me in layman's terms how this is taken care of in a web framework? I might get around to looking at how some established framework has done it, bu...

What % and & in this code?

I wonder what % and & in the following PHP code do. $num_one = rand() % 10; $num_two = rand() & 10; Thanks in advance. ...