php

selected entry with a drop down menu in php

I have this drop down list, displaying all the files from a folder, one of which will be selected for use. Is there a way to show which file is selected when you load the page? at the moment it says "select a file" every time. <select name="image" type="text" class="box" id="image" value="<?=$image;?>"> <option value='empty'>Select a fi...

Storing Passwords in reversible form

I have a PHP app that needs to run bash scripts, and provide a username & password (for remote systems). I need to store these credentials somewhere that is accessible by my PHP (web) app. The logical place is the database (currently MySQL, but will be agnostic). The problem with the "standard" way of hashing and storing the credentials,...

What program do you use to edit php remotely and then upload to your server?

So I am just starting out developing PHP web applications and have finished setting up my server with the following: Ubuntu Server Apache2 PHP MySQL VSFTPD and all the other goodies... Currently when I edit files, I have two methods to update/upload them to the server. I can use vi on the server to make small changes or I can use Ne...

When to use Bitwise Operators during webdevelopment?

Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators. Do you use Bitwise Operators? Why do you use them? What are some example use cases? Please remember that this question is specifically intended fo...

Can one convert a MySQL connection to a PDO connection?

I work on a app which has only one way to get a working DB connection: a function that returns a MySQL connection resource. Is there any way for me to convert that MySQL connection to a PDO MySQL connection? I don't have access to the MySQL server in any other way, no username, password, nothing. I can't see/get the file with the funct...

What is the best way to insert HTML via PHP ?

Hey, Talking from a 'best practice' point of view, what do you think is the best way to insert HTML using PHP. For the moment I use one of the following methods (mostly the latter), but I'm curious to know which you think is best. <?php if($a){ ?> [SOME MARKUP] <?php } else{ ?> [SOME OTHER MARKUP] <?php } ?> Opposed to: <?ph...

PHP SimpleXML, CodeIgniter and Apache with Suhosin

I have an application I am writing in PHP5, using the CodeIgniter framework. I have it running on both Windows (using Xampp) and Ubuntu (using standard Apache, PHP, MySQL stack). I have a form, that takes XML, parses it (using simpleXML) and posts the results into a database. On Windows - no problem, works as intended. On Linux - big ...

rollover effect using Jquery

Would you please help me in making a rollover effect using jquery, what i want to do is when someone hover over any of the menu items the text slide down and disappear and a picture slides from the top down to the center (e.g. you could see this effect here panda as you can see the picture slide down from the top but the text does not sl...

Find JPEG resolution with PHP

Calling all PHP gurus! I understand that you can use getimagesize() to get the actual pixel height and width of an image in PHP. However, if you open an image in photoshop and look at the image size dialog, you notice that there is a resolution value that determines the print size of the image. Given an arbitrary jpg image file, I need...

Remove a child with a specific attribute, in SimpleXML for PHP

I have several identical elements with different attributes that I'm accessing with SimpleXML: <data> <seg id="A1"/> <seg id="A5"/> <seg id="A12"/> <seg id="A29"/> <seg id="A30"/> </data> I need to remove a specific seg element, with an id of "A12", how can I do this? I've tried looping through the seg elements an...

PHP tag library

I'm writing a small web app as a side project. It's done in PHP. Boy, how I loathe PHP. Well, actually, I don't hate PHP per se. I can't stand HTML intermixed with code. I can barely look at one of those templates without feeling nauseated. I know, when you have an army of "web designers" at your disposal, and you are the only develope...

Is there a way to find how how "deep" a PHP array is?

A PHP array can have arrays for its elements. And those arrays can have arrays and so on and so forth. Is there a way to find out the maximum nesting that exists in a PHP array? An example would be a function that returns 1 if the initial array does not have arrays as elements, 2 if at least one element is an array, and so on. ...

How to change character encoding of a PDO/SQLite connection in PHP?

I'm having a little problem with a php-gtk app that keeps running into non-utf8 strings, I had found that the problem is in the database connection, even when the database is supposed to be in UTF-8. I had tried with the "SET CHARACTER SET utf8"(MySQL way) and the "SET NAMES UTF8" and nothing happen (there isn't any information about no...

Is Ubuntu an acceptable distro for running a production server?

I'm not a great Linux expert, but I'm comfortable running my Ubuntu desktop. I've also got a little experience running Ubuntu as a server as well, for my home network. At work, we're considering switching away from our current Solaris based setup to something Linux based. Our sysadmin is pushing for something like RedHat Enterprise or...

javascript problem

i have a php script and i'm using ajax with it . i have a textarea form connect with the ajax class the problem when i pass a text like ( &some text ) the function return an empty text ,i geuess that i have a problem with (&) , what is the problem here ? here the javascript function function sendFormData(idForm, dataSource, divID, if...

Handling data in a PHP JSON Object

Trends data from Twitter Search API in JSON. Grabbing the file using: $jsonurl = "http://search.twitter.com/trends.json"; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); How do I work with data from this object. As an array? Only really need to extract data from the [name] values. JSON object cont...

Zend Framework - Is there a script to index static content from Views?

Hi, I'm wanting to add a search box onto my website - which is built using Zend Framework 1.6 - using Zend Search Lucene. The majority of my content is static, and held within Controller Views. Does anyone have a script that can index content from the views, and add them into the Lucene search database so I can search them? Many than...

PHP/MySQL - How do you determin the field names from a given query result?

Given a result set, how can I determin the actual names of the fields specified in the query (NOT their aliases). $query = "SELECT first AS First_Name, last AS Last_Name FROM people"; $dbResult = mysql_query($query); $fieldCount = mysql_num_fields($dbResult); for ($i=0; $i<$fieldCount; $i++) { // Set some values $fieldName ...

How quick is switching DBs with PHP + MySQL?

I'm wondering how slow it's going to be switching between 2 databases on every call of every page of a site. The site has many different databases for different clients, along with a "global" database that is used for some general settings. I'm wondering if there would be much time added for the execution of each script if it has to conn...

PHP - Editing multiple array values (if they exist)

I have a multidimensional array. I need to search it for a specific range of values, edit those values and return the edited data. Example array: array(3) { ["first"]=> array(1) { [0]=> string(4) "baz1" } ["second"]=> array(1) { [0]=> string(4) "foo1" } ["third"]=> array(1) { [0]=> string(4) "foo...