php

Return Data and Type of mysql_fetch_array()

Consider the following 3 standard statements $queryString = "SOME SQL SELECT QUERY"; $queryResult = mysql_query($queryString); $queryArray = mysql_fetch_array($queryResult); Question is : If the result set of the query is empty, what will be the resultant datatype and value of $queryArray after all three statements are executed ? ...

Reading in Malformed XML (unencoded XML entities) with PHP

Hi all, I'm having some trouble parsing malformed XML in PHP. In particular I'm querying a third party webservice that returns data in an XML format without encoding the XML entities in actual data. For example one of the the elements contains an ASCII heart, '<3', without the quotes, which the XML parser sees as an opening tag. It s...

How to call a JavaScript function from PHP?

Hello How to call a JavaScript function from PHP? <?php jsfunction(); // or echo(jsfunction()); // or Anything else? ?> Please let me know. the follow of my program is, from xyz.html (on a button click) it call a wait() in an external xyz.js. This wait() call a wait.php function wait() { xmlhttp=GetXmlHttpObject(); var url="...

How to implement an inventory system for a game?

How would I go about implementing an inventory system for a game in PHP? I've been trying to figure out a way so that items can be dynamically used instead of just sitting in your inventory, e.g. equipping weapons, using potions, teleporting, etc. The only solution I can come up with is to store PHP code in the database, and fetch it wh...

What type of hash does wordpress use?

What type of hash does Wordpress use? Here is an example of a Wordpress hash: $P$Bp.ZDNMM98mGNxCtHSkc1DqdRPXeoR. ...

Which PHP Framework is right for this project?

Hello all, I have asked this question before (didn't get a definite answer) and have read a lot of similar questions to this and I apologize to those getting tired of these sort of questions. :) I have a fully working PHP web project using my half pint PHP skills in a procedural way. But its not up to scratch at all. It can break at an...

Doctrine Named Queries: Specifing limit on query call

Hey guys! Let's imagine something like this: class MyTable extends Doctrine_Table { public function construct() { $q = Doctrine_Query::create()->from('MyTable t') ->orderBy('t.creationDate DESC') ->limit(5); $this->addNamedQuery('top5', $q...

PHP Maths Equation Function

What i am really looking for is a maths equation function that takes in a string representing and equation and calculates the answer as a return type For Example "(((4 * 5) + 6) * 2) / 8" OutPut: 6.5 So in coding tearms something like print calc("(((4 * 5) + 6) * 2) / 8"); Is there already a class or a function that some angel has...

cakephp & nginx rewrite rules

Hi somebody please help me out, I’m trying to setup a cakephp environment on a Centos server running Nginx with Fact CGI. I already have a wordpress site running on the server and a phpmyadmin site so I have PHP configured correctly. My problem is that I cannot get the rewrite rules setup correct in my vhost so that cake renders pages ...

Can you detect what framework a website is running on or what cms they use?

If you have a suspicion that a website is running on a certain framework or using a certain CMS is there a way to tell for certain? I have found methods for drupal using the Live HTTP headers plugin (http://www.lullabot.com/articles/is-site-running-drupal) but I am currently looking for a way to figure out if a site is using the Zend fra...

document object confusion

In one php file (file1.php), I execute another through <form action="file2.php" method="POST"> yet within file2, I want to access html elements from file1.php, via document.getElementById(). Yet, the document object is different for file1 and file2. How can I access file1's elements from within file2? ...

Should my database driver classes support replication (PHP)?

Hello, I'm currently writing a PHP application and drivers (classes) for the database engines. I was wondering if I need to write a replication support (master-slave)? I'm a bit new to this, so, what kind of things should my project or classes worry about if I want to support load balancing/replication? Oh and this is about MySQL. ...

PHP simple proxy

I need a simple proxy PHP function/script that can download a file from a foreign domain, and also allow me to modify the data (as strings) before retransmit. Any ideas better than "readfile($url)" ?? ...

Do SQL connections opened with PDO in PHP have to be closed

When I open a MySQL connection in PHP with just PHP's built-in MySQL functions, I do the following: $link = mysql_connect($servername,$username,$password); mysql_select_db($dbname); //queries etc. mysql_close($link); When I open a connection with PDO, it looks like this: $link = new PDO("mysql:dbname=$dbname;host=$servername",$userna...

How to get timezone hour offset and account for DST with PEAR::Date?

I am trying to get the offset hours from UTC, given a summer date. My system time is set to America/Los_Angeles. I have the following: require_once("Date.php"); $dateTZ = new Date_TimeZone('America/Los_Angeles'); echo $dateTZ->getOffset(new Date('2009-07-01 12:00:00'))/1000/60/60; This prints '-8'; shouldn't it show '-7'? echo $da...

Which characters should I escape/sanitize for file names?

Hi all, I need to sanitize some data which will be used in file names. Some of the data contains spaces and ampersand characters. Is there a function which will escape or sanitize data suitable for using in a file name (or path)? I couldn't find one in the 'Filesystem Function' section of the PHP manual. So, assuming I have to write my...

File Checkout/Version Control on PHP site

I realize that this question has been asked 100times but none that I have found really answers my questions. We have multiple developers in multiple locations working on the same project. Some use Windows, some use Mac, our server is Linux, and each developer uses a different development application (Dreamweaver, Eclipse, etc). Each dev...

PHP - Function to skip strtolower() if variable contain "wikipedia.org"

Hello, My site allows users to enter URLs into a database. I am using the code "$site = strtolower($site);" to make all of these URLs lower-case. However, I just realized that Wikipedia URLs are case sensitive, so I would like to avoid using "$site = strtolower($site);" on Wikipedia URLs, all of which contain "wikipedia.org". How co...

Accessing a PHP-set memcache key from Python

I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing "local variable 'val' referenced before assignment". I'm sure I'm looking for the same key, and there's only one mc server available to either app (lo...

MySQL between query returning redundant results

SELECT webcal_entry.cal_id, webcal_entry.cal_name , webcal_entry.cal_priority, webcal_entry.cal_date , webcal_entry.cal_time , webcal_entry_user.cal_status, webcal_entry.cal_create_by , webcal_entry.cal_access, webcal_entry.cal_duration , webcal_entry.cal_description , webcal_entry_user.cal_category FROM webcal_entry, webcal_entry_user ...