php

php and mysql help, working with multiple database

Hi, I need to work on multiple database, and below is my current code. Following code seems to be very very slow and having issues with multiple connection while I view the mysql connection list. So can anyone let me what's wrong with the code and help me to correct the issues and faster performance. $dbHost="localhost"; $dbUser="use...

Wordpress / PHP - Cache custom queries ?

Hi So I'm making a plugin that gets a set of posts (using wp_query), and it does this every time you refresh a page. Can I cache the query results so the page gets generated faster? If so, how do I do it? because WP_cache functions don't work even if I enable cache in the config file. A alternative to wp_cache seem to be transients. ...

Loop through database rows and create a single array

Hello all, I have nooby PHP question that I can't figure out! I loop through rows from my database: $data = array(); while($row = sqlsrv_fetch_array($queryResult, SQLSRV_FETCH_ASSOC)){ $data[] = $row; } $data now contains an array within an array how can I have it so that its still just a single array? Thanks ...

Send content from node.tpl to page.tpl

Hi all, I have a div container in the page.tpl file, which I want to use as a popup layer for images. These images are recieved from the nodes. So every time i hover over the images i want to show the popup layer with content from the specific node. How can I send content to that specific popup div from the node.tpl? //Kris ...

Using HTTP GET with PHP Oauth PECL Library

Hi, I'm having a strange problem using PHP's OAuth PECL library - I seem to be unable to get it to make requests via GET. I'm using v1.0.0. This is the request: $oauth = new OAuth( $network->get_consumer_key(), $network->get_consumer_secret(), OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_FORM ); $oa->enableDebug(); $oa...

What does $_GET['key'] return if the key is not set?

What does $_GET return when the index is not set? (Couldn't find anything in php manual about $_GET.) I wrote this to check, if the $_GET['id'] isset - and if it is not, set $id to false: <?php $id = (isset($_GET['id'])) ? $_GET['id'] : false ?> ...

jQuery .post with array of dynamic variables

I've just tried and more or less given up on sending an array to a jQuery post function, which are then layed out as POST variables. I've read a lot of the similar questions on here, but none seems to quite get it. I tried all I could, closes was the following function sendValue(requestArray, requestAction){ $.post("requests.php", { ...

Simple template var replacement, but with a twist

So I'm setting up a system that has a lot of emails, and variable replacement within it, so I'm writing a class to manage some variable replacement for templates stored in the database. Here's a brief example: // template is stored in db, so that's how this would get loaded in $template = "Hello, %customer_name%, thank you for contact...

Storing a URL value in MYSQL

Hi everyone, I am developing an URL bookmark application (PHP and MySQL) for myself. With this application I will store URLs in MySQL. The question is, should I store URLs in a TEXT column or should I first parse the URL and store its components (host, path, query, fragment) in separate columns in one table? The latter one also gives m...

Typo3 produces wrong moved location

Hi there, we are running a typo3 host with realurl and typo3 version 4.4.0 - now something strange happens, if a page isn't found typo3 throws a 302 (moved) - which seems the normal behaviour of typo3 - but the location for the moved document isn't my domain something like this is produced http://otherdomain.com/servlet/domain/myrealdo...

functions in require("x.php") works in some of the code, but cannot be called in the next?

Hi. I have this code ` require("db_connect.php"); function xx() { $conn = db_connect(); //here it works (...) date_default_timezone_set('Europe/Paris'); if(time() <= $x[0]){ (...) }else { (...) for...

Using session to reduce CPU load [PHP]

I have a page which performs following operations: Executes a query in a DB (More precisely, select u.user_uid, ut.user_metatada from users u, user_tag ut where u.uid=ut.uid. One user can have one or more metadatas) Generates an array of data based on result of the query Performs some complicated operation on these arrays (More about t...

PHP Server Information

I'm trying to write some code that various sites will embed, calling a script on my server. That script streams the binary data for an image and spits it into an image tag. However, I'm trying to control who has access to that script. So if I hand out my embed code to, say, yourwebsite.com, I want to make sure the client requesting th...

Bulletproof Twitter followers count with PHP?

Hi, I'm trying to display a number of Twitter followers using PHP given a username. My code looks like this: function tweet_count() { $name = get_option('ws_twit'); $twit = file_get_contents('http://twitter.com/users/show/'.$name.'.xml'); $begin = '<followers_count>'; $end = '</followers_count>'; $page = $twit; $par...

Is it common to store a users password in a PHP Session?

New to php Sessions here. My stored user data is pretty minor and not very sensitive but of course I still want a secure site. I have stored their password hash in my db with salt. Do I need to validate a user on every page of my site using their password, or is that overkill? In other words, if they have successfully "logged in" and I ...

PHP Question - How to create an array out of a string?

In my database, some field settings are serialized and stored. When I do this: print_r(unserialized($r['settings'])); I'll get this: Array ( [prefix] => [suffix] => [min] => [max] => [allowed_values] => 1|Common 2|Rare 3|Almost Extinct ) I'm trying to create an array based on the values for allowed_values like this: Array (...

PHP Function to Indent PHP Code?

I'm looking for a PHP function that will take a string like this: function func() { $testing; $testing; } And turn it into something like this: function func() { $testing; $testing; } Does anyone have any recommendations? ...

Is there an easier way to implement openid?

I've been banging my head against the wall trying to add openid to my PHP webapp, but none of the libraries provided seem to do it in a clean and simple way. Is there any way to implement openid SSO without being forced into more design choices than is necessary? The janrain library - being the most popular - is also the most unwieldy,...

PHP change file extension

Hello, I am trying to change a file exenstion, but whenever I do the file seems to corrupt. $oldFileName = $targetDir . DIRECTORY_SEPARATOR . $fileName; $newString = preg_replace('"\.tmp$"', '.jpg', $oldFileName); rename($oldFileName, $newString); The code works and changes the extension, but yet the file when downloaded, comes up as...

Deploying Django with no CGI available?

I need to deploy a Django project on a shared server which I have no root access for, and no administration capabilities whatsoever. Each user on the server has a dedicated directory from which Apache serves that users files (public URL would be /~username/). Problem is, Apache on this server has no CGI capabilities, no mod_python, no ...