php

In PHP/MySQL should I open multiple database connections or share 1?

I am wanting to hear what others think about this? Currently, I make a mysql database connection inside of a header type file that is then included in the top of every page of my site. I then can run as many queries as I want on that 1 open connection. IF the page is built from 6 files included and there is 15 different mysql queries,...

PHP - Shorter Magic Quotes Solution

I'm writing a app that needs to be portable. I know I should disable magic quotes on the PHP configuration but in this case I don't know if I can do that, so I'm using the following code: if (get_magic_quotes_gpc() === 1) { $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while (list($key, $val) = each($process)) {...

View Source and View Generated Source in firefox addons Web Developer

I use Firefox Web developer everyday. Now I found some of my website need to use View Generated Source rather than View Source. Because View Source gives a blank outputs. It seems it is relating to the following code. I am hoping someone can tell me why it needs View Generated source. And is there anyway I can modify the code so tha...

Headache with this programming problem. (PHP, Tiff images and Duplex printers)

Hi, i'm just feeling that my head will explode unless someone help me with this problem: I have stored a pair of TIFF images (related by a common key) for each one of almos 100.000 registries. And I create a PHP script that receives a key and echo the tiff image, so the browser return the tiff image: <?php // Determine the primary ...

Tracking outgoing links with Javascript and PHP

I have tryed it using jQuery but it is not working. <script> $("a").click(function () { $.post("http://www.example.com/trackol.php", {result: "click" }, "html"); }); </script> <a href="http://www.google.com"&gt;out&lt;/a&gt; ...

PHP date function showing wrong week

Why is PHP date("W") showing that the current week is 2? Shouldn't it be on week 3? In the PHP documentation it says: weeks starting on Monday. Does that mean it just ignored the first 3 days of this year? ...

Simple way to select chosen option in <select> from the value given by $_POST?

How can i add the selected="selected" bit to the option in an HTML <select> input from the sent $_POST data without an if statement within each option? ...

MySQL LIKE question

I have a script: $friendnotes = mysql_query("SELECT nid,user,subject,message FROM friendnote WHERE tousers LIKE '%$userinfo[username]%' "); And the content in the "tousers" table of the database: Test Example User That script appears to be working well However, if there is a user called "Test2", it would also display content th...

$_REQUEST not created when using variable variables?

Consider the following snippets of code: Exhibit A: $_REQUEST = json_decode(stripslashes(json_encode($_REQUEST, JSON_HEX_APOS)), true); Exhibit B: ${'_REQUEST'} = json_decode(stripslashes(json_encode(${'_REQUEST'}, JSON_HEX_APOS)), true); Exhibit C: ${'_' . 'REQUEST'} = json_decode(stripslashes(json_encode(${'_' . 'REQUEST'}, JSO...

How to preserve language status using PHP sessions and cookies

I have this in my index.php: <?php include_once 'file.php' ?> then I have <html> some content </html> and I have this in file.php: <?php session_start(); header('Cache-control: private'); if(isSet($_GET['lang'])) { $lang = $_GET['lang']; $_SESSION['lang'] = $lang; setcookie("lang", $lang, time() + (3600 * 24 * 30)); } else if(isSe...

PHP: How can I turn a mysql TEXT or BLOB type into a string?

I have a frustrating experience in PHP because I keep getting my MEDIUMTEXT field returned as a non-string string. When I check the variable's type it says it's a string, but it's actually an array, basically a character array so I do: while ($row = mysql_fetch_assoc($records)) { print_r($row["myText"]); } Which instead of printing ...

PHP: how to serve right content-type (depending on file extension?)?

I'm using the scripts below to gzip some CSS and JS files. It works nice - except for serving JS files with the wrong content-type (and not the appropriate application/x-javascript). How could I improve the PHP code in order to serve the right content-type? Thanks! .htaccess: AddHandler application/x-httpd-php .css .js php_value auto_p...

getting time remaing from file upload with php

i want to upload a file in a way that user can see how many time is remaining from upload...with php and jquery $.ajax(); ...

best solution for upload progress bar for shared server user

i have seen lots of solution, but what is the best stable solutin for no-administrator user who cant config server. i found some of these: using apc extension perl cgi instead of php flash based using js framework im not sure i could use extension, not understand perl to control over the process, and totally not use flash in mywebsit...

monitoring disc reads

Hi, i want to use apc in php, to avoid disc reads when including files. But how can i know if files are really coming from shared memory, instead of disc reads? Does anyone know how to measure the number of disc reads for a php script, or in a time interval? (on windows server 2003) Thanks a lot in advance, regards, Charles ...

Zend Framework controller load failure puzzle

Hello, all :) I have a .htaccess file that looks like this: SetEnv APPLICATION_ENV development RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] If I browse to my site I'm testing with, say ht...

Not able to change the size of captcha in PHP

I have the following captcha plug-in. I tried changing different font-size but none of them worked. Could anyone tell me how to change the font-size please. Thanks in advance. EDITED: Code Here. ...

How to use images as nav buttons in Wordpress?

Here is my navbar in header.php <!-- NAV --> <div id="nav"> <ul> <li><a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/navbar/home.png" alt="Ad image" /></a></li> <li><a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ...

Add a word to the ending of every third sentence.

Hello I'm creating a "fun-translator", and I'm trying to add a word to the end of every third sentence or so. It gets another page HTML code and translate it into teen language. But I want to add a word to every third sentence. I've been using this line for now: $str = preg_replace_callback('{<.*?[^>]*>([æøåÆØÅ !,\w\d\-\(\)]+)([<|\s|!|...

Use PHP to format an input SQL query as HTML?

What I am looking for is a php function that takes an unformatted query like this: $sql = "select name, size from things where color = 'green' order by price asc"; so that it would appear in an HTML page something like this: SELECT name, size FROM things WHERE color = 'green' ORDER BY price ASC'; There's some co...