php

How do I make my site automatically sign out a user when they close their browser?

Let's suppose I have a sign-in form. When I sign in successfully I am redirected to the logged in home page. Currently, when I close this page without signing out, and re-open Firefox, this logged in home page is started again. I want it so that when the user closes their browser the session is the session is expired and when they nex...

original script for pagination

This is my pagination script and i wonder why im getting these errors in IE : function GetXmlHttpObject(){ var a; try{ a=new ActiveXObject("Msxml2.XMLHTTP"); } catch(d){ try{ a=new ActiveXObject("Microsoft.XMLHTTP"); } catch(c) {a=false;} } if(!a&&typeof XMLHttpRequest!="undefined") { try{ ...

PHP array as variable name

How to send an indexes name for php array vairable. the array is $array = array('Somthing'=>array('More'=>array('id'=> 34))); and now I want to display this thing but with a variable name I don't know how to explain so I write what I want to have. $index_name = '[Something][More][id]'; $array{$index_name}; Is it possible in any...

Find - using PHP and wrap everything after in <span>

I am printing using PHP <?php echo $article->link($article->title()); ?> This string holds something like "Team Member - Job Title" What id like to do is wrap everything after the dash in a span so i can change its colour. Any help would be greatfully appreciated. ...

Easier way to populate form data and validation data in Code Igniter?

I'm new to code igniter. I'm following the form validation tutorial found at: http://www.codeignitor.com/user_guide/libraries/validation.html I find I am typing too much in the view to get the form to re-populate. For example, here's what one of my INPUT fields look like: <input type="text" name="email" value="<?=$this->validation->...

Mysql/Apache connection error from Php script

I am trying to use php. I wrote a small script as instructed in the tutorial. I am using Wampserver 2.0. Connection is fine. But whenever I try to execute the script, I get "Apache HTTP server encountered a problem and needs to close" error message. My localhost is working fine. Normal php scripts without mysql statements in it is workin...

Calling a function using zend framework

I am currently using zend framework and working with jquery and php. Trying to implement an autocheck username availability. For the following code, I need to call my user_availability.php which is in my controller folder. I did /controllers/user_availability, ../user_availability but it doesnt call that page. Can anyone help? $.post...

how to get data when we provide multiple value of a field

i got have 3 id in a string let $x="6,3,5" now i want to get all color information from tbl_color where color id are 6, 3 and 5. i made this query, whats wrong with this $sql=" SELECT * FROM tbl_color WHERE color_id IN(".explode(',',$x).") please suggest right query ...

Connection to secure FTP Server from PHP

This question is in line with this question, I am trying to connect to secure FTP Server and it is not able to connect, wierd part is that I am able to do ssh and connect to the server but when I try to do it from php code using few different approaches but it is not working Approaches: FTP Wrappers ftp_connect & ftp_login ftp_ssl_con...

Bug in my preg-match

Hai all i have a big problem right now i have this sample code: preg_match_all("/\[BLOG\=\[(.*)]](.*)\[\/BLOG]/U", $this->soruces , $match_list ); and i don't know why its not will working, its print this out to me Array ( [0] => GROUPID=23|CATID=28|SORT=ASE [1] => GROUPID=23|CATID=29|SORT=ASE [2] => GROUPID=23|CATID=30|SORT=ASE ) ...

Hiding messages for logged in users?

We currently have a message option on our site that displays any message we add via the CMS to logged in users, but what would be the best way to offer a 'hide' option? This way if that particular user doesn't want to see the message again they could hide it? Any suggestions welcome... ...

php merging arrays

In the multidimensional array below, I would like to merge arrays that have the same merge_id. I'm not sure "merge" is the right word: in the example below, array['0'] should become array['0'] with in it array['0']['0'] and array['0']['1'], the latter being equal to array['1']. I hope this makes sense ... The array comes out of the db s...

Making a checkbox recognize its intended data

Level: PHP Learner I'm stuck with a checkbox problem. I have a db that contains names and unique id numbers. Using a query, I am pulling a selection of students and showing them to a user in an ultra simple HTML table on a form. Each row begins with a checkbox. The method is POST. So far, so good. My table kinda looks like this:...

Using a dash (-) instead of a plus (+) in Zend Framework URLs

by default it seems my ZF is separating multiple parameter words with plus signs. eg. /product/test+product+name I would like to use -> /product/test-product-name Here is the line from routes.ini routes.product.route = "product/:productName"<br /> routes.product.defaults.controller = product<br /> routes.product.defaults.action ...

Adding a class to the last row in a foreach loop

HI all, This code works perfectly printing all 5 results with borders on the bottom of each list item through CSS. However the last item id like there to be no border. How could i add a class to the list item on the last iteration? <?php list($parent) = split('/', $this->url); ?> <?php $last_articles = $this->find('/news')->childre...

Strange PHP output corruption

I'm having a very strange output corruption on one of my PHP sites. Sometimes, a piece of HTML code is displayed, rather than the tags being interpreted. It looks like some characters are missing, messing up the tags. See the example below: the second line should just be a link to c1, but due to some reason part of the target URL is show...

Zend Framework handle exceptions gracefully in production environment

My application handles errors happily in development, both errors and exceptions. When I switch to production the application just returns a blank page as the config is set to not display errors. Is there a standard method in ZF for sending visitors to a nicely formatted 'Page not found' using a layout from the application so that they a...

Can php detect if javascript is on or not?

I have page which created dynamically. Now I want to add ajax function, so I want to add if statement to change the outputs. if(js is on){ ... ... echo "js is on"; }else{ ... echo "js is off"; } Is there any way I can detect if js is on with php? Or is there any way I can remove/hide it by jquery? Thanks in advance. ...

MySQL to Oracle help

I have a few questions about using mysql and oracle in a PHP app. 1) Is it possible to code my PHP app to easily switch between these 2 databases? (Use MySQL for a year and then easily switch a "DB" file and it will run on Oracle?) I believe some large PHP projects have support for multiple database types. 2) Does Oracle have some...

how to organize all js, css, php and html code?

Now I know that you can use OOP and MVC to organize, but that is just for PHP. Let's say, I add a new window that pops up when a user clicks on a link and it displays a form with JS validations and it is CSS styled. Here we got 4 codes: JS, CSS, PHP and HTML (with some PHP snippets). How would you organize all these codes? Because whe...