php

PHP explode() function issue.

Please help me out on this explode() function issue. I am getting unexpected results for the third scenario, what's the explanation? EDIT: The value $page_string is actually from the database. This time I did the tests using var_dump instead of echo. The strings, How does php count them? How is "15&page" count 11? var_dump($page_string...

How can I query two different databases in a single query using MySQL?

I have two websites that post news information. I just got a request to make a single page for one of the sites that shows the mixed results from both sites. They are located on the same server and the tables are close to identical, but I am having problems figuring out how to combine the two queries. The postings need to be sorted by da...

how do php share data without access a DB

I have two pages and I want to pass data to each other. How can I do this without accessing a DB? Sessions? Cookies? someother magical way? If you know how, can you please post sample code? Thanks ...

PHP Session_start is hanging

Kind of a weird issue, ok here is my setup... domain.com calls reads from an Iframe on sub.domain.com sub.domain.com makes an ajax call to sub.domain.com/call.php sub.domain.com returns ajax call to domain.com AKA long-polling Now, everything works perfectly when there is no session data (I close the browser and restart the page). ...

PHP remove all caps

I use PHP to insert form entries into a MySQL database. Sometimes users enter text in all caps. Is there any way to change it so that only the first letters are capitalized? ucwords(strtolower($word)) won't work for me because I do not want to capitolize the first letter if it was not already capitalized. My main concern is when peop...

What's the recommended way to store current time using PHP and MySQL?

My initial approach was: $current = time(); // save this to column CURRENT_TIME with column type VARCHAR //retrieve it like this $retrieved = mysql_query(....) //assume query for getting the stored time value $time = strtotime($retrieved); I have come across the following approaches: use gmstrftime to handle gmt use INT instead of ...

Is it better to filter a resultset using a WHERE clause or using application code?

OK, here is a simple abstraction of the problem: 2 variables(male_users and female_users) to store 2 groups of user i.e. male and female 1 way is to use two queries to select them : select * from users where gender = 'male' and then store the result in male_users select * from users where gender = 'female' and then store the result...

how do I use mysql real escape string?

The code here is still incomplete because I'm still going to ask you guys on what the proper format/syntax of using mysql escape string. Im still a beginner in php and I want to learn how to avoid sql injections. Is the code below correct? $con = mysql_connect("localhost","root","mypwd"); if (!$con) { die('Could not connect: ' . ...

Where to save customized behavior for doctrine in a symfony1.4 project?

So that the behavior template can be autoloaded when necessary. I'm confused by the complex settings. ...

lazy loading of java script in php

Hi, I am using the Google visualization for drawing graphs into my website. This involves a lod of java script. <script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; <script type="text/javascript"> google.load('visualization', '1', {packages: ['annotatedtimeline']}); </script> These two lines of scr...

How can I link main menu links to submenu links in Joomla!?

I have main menu with sublinks, so when you click mainmenu link, it should go to default submenu link. For example: Main menu: Homepage | Information Information submenu has Contact and Location selections and Contact should be active when Information main menu link is activated. ...

PHP support printer settings?

Hi all, In VB.net i heard about there is an option to change printer settings like page type and margins. when we want to print contents for a web apps we use javascript window.print() option, but i want to set page settings through php how it is possible? remember i want to take a print in client machine through browser not in a web se...

PHP Paypal integration test account

Hi there I am going to work on a project that involves Paypal function. My question what kind of account do I need to do the test? Do I need merchant account? And if you also have a good reference site please share it here. Thanks ...

php & mySQL: Which of the following query is faster? Why?

Which of the following 3 Queries will be faster? Why? I use such queries with a lot of other joins a lot within my app. so is there any way I can benchmark their speed? If yes, can you please mention what it is/they are? Query 1: $q = "SELECT COUNT(books.id) FROM books INNER JOIN books_type ON books.id = books_type.id WHERE books_t...

Select item from many-to-many table that has all these details... proper solution?

(PHP/MySQL) Let me preface by saying that this works, and that I'm wondering if there's a cleaner way. This seems a bit... brutish? And I'm not known for my efficient coding. :-/ TABLE (many-to-many) scenid mapid AA 01 AA 02 AA 04 BB 01 BB 04 CC 02 CC 03 CC 05 DD 01 DD ...

Trying to run the function socket_recvfrom but it returns an error saying: socket_recvfrom(): unable to recvfrom [0]: The operation completed successfully.

Hi! I am running a function: @socket_recvfrom($this->socket, $buf, 8192, 0, $from, $port); but this returns an error saying: socket_recvfrom(): unable to recvfrom [0]: The operation completed successfully. Anyone who has an idèa about this? What does this mean? Morten ...

Why is gzip compression not working?

This is an odd one. I am slowly rebuilding a website on a live server. Some sections of the site have been rebuilt and therefore the code is placed in a subdirectory of the home dir (ie:/mysite/newcode). I had successfully gzipped the old site using ob_start("ob_gzhandler"); So, i have applied the exact same code for the new code. Howe...

How to match a string which doesn't contain a dot (.) using regular expression ?

How to match a string which doesn't contain a dot (.) using regular expression ? ...

generating url Symfony sfFormExtraPlugin autocompleter

Autocompleter has a required option - url. Problem is, it is used in Form.class where neither url_for() nor $this->getController()->genUrl() works. All the examples I saw use url as literal string, i.e. $options = array('Model' => 'Model', 'url' => '/path'); Maybe I'm getting something wrong, but I believe writing urls as string is no...

mysql count include to json object

Hi! I made a php/ajax/mysql/json script for my site, to show all the tags. If i GET the page id it will show me all the tags of that page. But! In my main page i'd like to show all tags, from all pages WITH a counter. For example if i tagged 4 pages with "ilovestackoverflow" i'd like to see in my main page "ilovestackoverflow (4)" i ...