php

Get array element after performing a function on it??

Hey all, I'm looking to see if there is some PHP syntax that I'm missing that will allow me to grab the contents of the array I just manipulated using a function.. Good example: $firstElement = sort($myArray)[0]; Where normally I would have to do this: $myArray = sort($myArray); $firstElement = $myArray[0]; Any clean way of doing...

Complex (ish) SQL join and count query

Hi, I'm trying to create a simple poll function using php and sql. I have three tables: Questions Which simply contains each question asked question_id | question_text | created_at Answers Which contains each answer for each question question_id | answer_id | answer_text Answered Questions Which records who has voted for each opt...

Is it possible to have 2 limits in a MySQL query?

Ok here is the situation (using PHP/MySQL) you are getting results from a large mysql table, lets say your mysql query returns 10,000 matching results and you have a paging script to show 20 results per page, your query might look like this So page 1 query SELECT column FROM table_name WHERE userId=1 AND somethingelse=something else...

How to debug a PHP application?

Which is the best way to debug an PHP application as we can debug ASP.NET application with Visual Studio ? ...

Joining Tables With Zend Framework PHP

Hi, I am relatively new to the Zend Framework. I understand the usage of Zend_Table and can obtain data using the Zend functions from the table associated with that class. For example I have a video table and in another table I have the association between the video and what category it is in. Im a little stumped how to active a sele...

Smarty - difference between register_object and assign_by_ref

These are two of the options I have for exposing a PHP object to a Smarty template. I know that there are syntax differences between the two, but I can't find any information on why you would use one over the other. Can anyone explain the differences? Thanks, James. ...

Quote Creator - Best way to use SQL

Hi, I'm doing a quote creator tool. There is a table that will store all the customer info. Then there is a quote table which will share the customer_id key and store all details of the quote. I would like to store all details of the products quoted in the quote table. Now with a shopping cart you would have a products table with all t...

PHP Problem - PEAR Calendar Grid Not Rendering in Browser

Am trying to create a grid calendar using PEAR and PHP but when I preview the file in my browser I get the following: *Warning: include(Calendar/Month/Weekdays.php) [function.include]: failed to open stream: No such file or directory in /Users/x/Sites/p/testing pages/Pear_Date.php on line 8 Warning: include() [function.include]: Failed ...

How to echo xml file in php

How to print an xml file to the screen in php? This is not working: $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, 'http://rss.news.yahoo.com/rss/topstories'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close ($curl); $xml = simplexml_load_string($result); echo $xml; I...

Ajax error - "permission denied"

Sorry, this looks longer than it probably is but I thought I should include all the information! I'm using a simple Ajax script to dynamically bring content into a <div> on a page. The first request to load some new content into the div works fine, but if I've got an Ajax "back" link within the content which has just loaded, it seems to...

setTimeout with ajax chat

Ok Hi Help help help I am having a major problem with setTimeout it is not working and i did everything not working I am developping a chat system so i need to send and recieve messages (i test it by opening 2 browser windows) Here is the code i changed many times I hope any one can help me javascript $(document).ready(function() ...

eAccelerator doesn't always improve performance?

Ok I have read a lot of posts and articles on how GREAT eAccelerator is, I tested it on my home dev server and it slowed my pages down pretty noticably, could it be because: I don't have a lot of RAM? It only works to improve the speed of code sometimes? All the hype is false? Other? ...

How can I optimise this MySQL query?

I am using the following MySQL query in a PHP script on a database that contains over 300,000,000 (yes, three hundred million) rows. I know that it is extremely resource intensive and it takes ages to run this one query. Does anyone know how I can either optimise the query or get the information in another way that's quicker? I need to ...

Making correct use of chained routes in Zend Framework

I'm working on a multilingual site using the new Zend Framework (1.8), but I'm running into some trouble with the URL routing. It might be that I interpreted its meaning incorrectly, but well, never too late to learn. So, what's basically happening: The site consists of several parts, e.g. 'devices' and 'articles'. The plan is to form t...

mod_rewrite to get query string PHP

I asked a question a while ago to sort out my directory structure and you all solved my problem (Thanks!) but im now changing this site to another server and rewrite rule does not work. I cannot find the problem. I sent a support ticked to the hosting and they said: If that statement doesnt work then it will be either incorrect, or n...

Reloading Apache2 via Terminal in MAC OS X

Am trying to reload Apache 2 via /init.d/apache2 reload command in terminal but I get a command not found error and when I look at the etc/ directory in Finder I can't see any init.d folder. Is there somewhere else this init.d folder might be? ...

Is there any sites where users share custom PHP code?

Do you know of any websites that allow users to share there custom PHP functions and code snippets other then? It would be nice to compile a list of a few good resources http://www.phpclasses.org ...

PHP Bolding The 'x' Instance of a Variable In a String

Basically I have a variable which contains a few paragraphs of text and I have a variable which I want to make bold within the paragraphs. (By wrapping <strong></strong> tags around it). The problem is I don't want to make all instances of the word bold, or else I'd just do a str_replace(), I want to be able to wrap the first, second, fo...

Can't return a result set in the given context

When ever I try to call store procedure in mysql that sends back a result set, it keeps saying me that "can't return a result set in the given context". I've google it and some said it's mysql bug, some said you should change your mysqli driver and .... Situation : Using mysqli driver Client API library version 5.0.51a , PHP Version ...

How can I measure the speed of code written in php?

How can I say which class of many (which all do the same job) execute faster? is there a software to measure that? ...