php

Comparing String to Integer giving strange feedback

I'm really confused as to why this operation works. Can someone explain it? $test1 = "d85d1d81b25614a3504a3d5601a9cb2e"; $test2 = "3581169b064f71be1630b321d3ca318f"; if ($test1 == 0) echo "Test 1 is Equal!?"; if ($test2 == 0) echo "Test 2 is Equal!?"; // Returns: Test 1 is Equal!? For clarification, I am trying to compare the s...

mysql_connect() on localhost

I am trying to implement a little 'intranet' on my home network, but I am an apache/mysql configuration noob... Running fedora 10, and have apache, mysql, and php set up as well as i know how. However, when I try using a standard form with POST, the php script seems to error out on the mysql_connect(...); line. I don't get an error me...

Is there a way (or best practice) to markup the head (<th> equivalent) of a CSV document?

I am exporting data from a database using PHP to convert it into a CSV. I figured it'd be useful to provide the first row with a title (similar to the <th> element in HTML) so the end user would understand the column's meanings. Example ============= | id | name | ============= | 0 | tim | | 1 | tom | ============= Which would loo...

Access shared drive using OPENDIR

Hi friends, I want to display all the drives in my system through PHP, So i used opendir. Here a problem i had already mapped a drive in the name of Z: this drive not showing while we try to displaying the drives in browser. Basically i am having c: drive and additionally i have mapped the Z: drive from network connection. Please help...

PHP Boggle game

For a project I am considering building a Boggle type game in PHP. All of the solutions I have seen online have used some sort of tree or hash based approach. Are there any similar data structures built into PHP? Any advice on how to handle figuring out what words are present on a current board of letters? ...

Merge two arrays (key and content) in PHP

I have an array like the following Array ( [0] => "txt1" [1] => "txt2" [2] => "txt3") I have another array like it but with different content : Array ( [0] => on [2] => on) The aim is to get a final array with the keys of the second and the content of the first, it's like merging them. So that the final result is : Array ( [0] => "...

Page not found by ZendRouter: treats folder name as controller name

I've tried to run ZF Quickstart app not from the root folder, but from webserver subfolder, like a usual php app, e.g. localhost/quickstart. When localhost/quickstart/guestbook gives page not found error: > Page not found > > array(3) { ["controller"]=> > string(10) "quickstart" ["action"]=> > string(9) "guestbook" ["module"]=>...

How do you do Unit Testing With an App that Uses an ORM?

I've looked through the various questions on unit testing but can't find one that specifically answers this question. I've got several PHP classes that contain functions that look like this: static function _setSuspended($Suspended, $UserID) { try { $con = Propel::getConnection(); $c1 = new Crit...

SQL_CALC_FOUND_ROWS / FOUND_ROWS() does not work in PHP

I use SQL_CALC_FOUND_ROWS in Mysql SELECT statement, to get the number of lines my SELECT would return without a LIMIT clause. $sql = new mysqli('localhost', 'root', ''); $sql->select_db('mysql'); $s1 = $sql->query('select SQL_CALC_FOUND_ROWS * from db limit 0, 3'); $s2 = $sql->query('select FOUND_ROWS()'); if($row = $s2->fetch_row()) p...

How can I generate unique random numbers in PHP?

I am working on a MCQ module and I need to fetch random questions from my database. The problem is that I seem to get duplicates. ...

Getting the Get Variable's Name

i have a need to get an undefined $_GET['$VARIABLE']. so that if a link comes into item.php?changingitemstyle=10101010101010 I need to find out how to extract the name of the variable not the value. Any ideas? ...

Common interface for different OpenID providers and Facebook

Is stack overflow uisng https://rpxnow.com/ for login in using different services. If so is it good, and does it have good (preferable free, preferable with PHP api) alternatives. What I'm looking for is a login page wich would allow users to login using major web open-id providers + facebook connect. ...

xmlHTTPrequest won't open ("GET" , url, true); I'm miffed! PHP

I've been trying to get a url to open but I'm miffed as to why this hasn't worked. The code is listed and explained below. Any help will be deeply appreciated. The object: function getXMLHTTPRequest() { var req = false; try { /* for Firefox */ req = new XMLHttpRequest(); } catch (err) { try { /* fo...

Persist nested jquery sortable list

The Problem: I have a nested list on my configuration page that looks like this: <a id='Save'>Save<a> <ul id='configuration-list'> <li id='e1'>Elem A <ul> <li id='ey'>Elem Y </li> <li id='ex'>Elem X <ul><!-- and so on until 5 levels of nesting --></ul> </li> <li id='ez'>Elem...

PHP problem in IE "supplied argument is not a valid stream resource"

I set up a thing so that, from various places on my website, I can link to a page called "linktothis.php" which will include a link to the referring page. It works fine in firefox, but IE seems to give it trouble and it tells me: Warning: fread(): supplied argument is not a valid stream resource in /usr/local/apache/sites/nextadvisor/l...

What is wrong with this PHP expression?

Can someone explain to me why the following returns empty arrays? $reg = "/(\[{(false|true)};{.+};{\d}\])+/"; preg_match_all($reg,"[{false};{abcde};{10}][{true};{fghij};{10}]",$matches); print_r($matches); ...

benchmarking PHP vs Pylons

I want to benchmark PHP vs Pylons. I want my comparison of both to be as even as possible, so here is what I came up with: PHP 5.1.6 with APC, using a smarty template connecting to a MySQL database Python 2.6.1, using Pylons with a mako template connecting the the same MySQL database Is there anything that I should change in that set...

How do I split an RTF document into individual pages using PHP

I have an RTF document that serves as a template for input data from a web page. I need to know how to break the base template into individual pages for display on the website. Is there a way to do this using PHP? I have tried searching through the RTF code inside the document, but cannot find anything that gives me a good breaking po...

Zend Framework Lucene Boolean / "Google"-like search

I'm working on the application at http://demos.zatechcorp.com/codeigniter/ In its current incarnation running on my machine, I loaded the ZendFramework inside Codeigniter, and generated an index, like this: // ... Some code that loads all the markets foreach ($markets as $market) { $doc = new Zend_Search_Lucene_Docu...

Is it possible to implement properties in languages other than C#?

During a bout of C# and WPF recently, I got to like C#'s properties: public double length_inches { get { return length_metres * 39.0; } set { length_metres = value/39.0; } } Noticing, of course, that length_metres may change from being a field to a property, and the code need not care. WPF can also bind UI elements to object p...