php

How do I run PHP code when a user clicks on a link?

I want to have a page run some PHP code when a user clicks on a link, without redirecting them. Is this possible with <a href=""></a> or with the javascript onclick event? ...

Acessing Mac applications from Ruby or PHP or Cocoa

I would like to access a couple of different Mac OS X applications from preferably Ruby, but I would settle for PHP. The applications are Elgato's turbo.264 and Apple's iTunes. Both have Applescript Libraries defined that would allow me to do what I want to do from Applescript, but I don't want to do this in Applescript. If I can't do th...

How do I loop through MySQL results easily?

I've been requesting MySQL results and looping through them like this: $query = "SELECT * FROM $table"; $result = mysql_query($query); for($i = 0; $i < mysql_num_rows($result); $i++){ echo mysql_result($result, $i, $row); //do something else; } you can probably see what happens. What if a row has been deleted? What if the firs...

Implement a unique page view counter?

I want to implement a user-facing view counter (similar to what SO has for question views) that tracks the number of unique views to a page. There are a couple of similar questions here but none seem to answer my question fully. What would be the best setup for this (in terms of database tables etc.)? Would it be good to add a 'views' ...

To get many tags for a question effectively from Postgres by PHP

How can you get many tags for a question effectively from Postgres database by PHP? I have tables tags and questions where I have the variables questions_question_id and question_id, respectively, for instance. One question may have many tags. I can select question_id, title and a tag from the tables. However, I do not know how to get...

PHP Conditional Logic

In PHP, is the following logic allowed If (x && y) //Do A Elseif (x) // Do B Elseif (y) // Do C Else // Do D Basically, are you allowed to use more than one elseif? ...

Whats wrong with this 403 error redirect

Hi have created a error.php for joomla to redirect 404 errors etc to a joomla article. The code below works for a 404 error, but a 403 returns a blank page. I can navigate to the page directly outside my script so it must be either my code or how it is interactive in it's environment. Thanks Stephen defined( '_JEXEC' ) or die( 'Restric...

How to use a MySQL database with ASP.NET site, without connecting during development time?

I need to access and download data from a MySQL database without connecting to the database during development in VisualStudio. Is there a way to program it blindly (since I know what the database looks like) like its done in PHP? Alternatively, can I use download the database schema and use it in Visual Studio? ...

Jquery uploadifiy realtime update

How can i send some parameters, that they aren't defined when the page loads, i have a select box, and i also need to send to php, the selected value.So here my code var _data = $('#art:selected').val(); $('#art').live('change',function(){ $selected = $(":selected",this); id = $selected.val(); _data = id; }); $('.vla'...

To understand an array in PHP when given the other variable in the array

Please, see Cha's answer where we are pretty close the final solution. We are debugging the code with these data database in PostgreSQL test sql-queries -- Problem related to the Unsolved problem in the code How can you refer to the php -element in the following array? I have the following data Array ( [1] => Array ( ...

Display query created with stmt

I have the following code for inserting new row into the database: $query = "INSERT INTO files_requests VALUES (NULL, ?, ?, ?, ?, ?, ?, {$userinfo['id']}, 0, ". time() .", 0)"; $stmt = $mysqli->prepare($query); $stmt->bind_param('isssss', $listID, $files, $filesize, $audio, $subtitles, $fansub); $stmt->execute(); Is there ...

Incrementing a table column and getting the new value (codeigniter active record)?

I have something like this: $this->db->set('val', 'val+1', FALSE); $this->db->where('id', $id); $query = $this->db->update(TABLE_NAME); How can I then go and get the new value of 'val'? Do I have to do another select or can I get it off of $query? ...

Using PHP classes to format html?

I have a class designated for a certain site. In that site I have different functions to retrieve data from the database and store that data into an array. I have other functions within the same class that take the data and format it into html and returns the html containing the data from the database. For example... function GetUserPr...

Run process with realtime output in PHP

Hi, I am trying to run a process on a web page that will return its output in realtime. For example if I run 'ping' process it should update my page every time it returns a new line (right now, when I use exec(command, output) I am forced to use -c option and wait until process finishes to see the output on my web page). Is it possible ...

Best way to get a photo's file extension type in PHP

I am re-building my photo-uploading section on my site, I am trying to learn as much as I can so I can do it securely but also with best performance. MY site has aound 15-20 photos uploaded per minute usually So is this method reliable for gettting the photo's file type, like jpg, gif, png? $fileType = $_FILES['image']['type']; ...

Initializing resources based on route and/or module

I'm using Zend Framework 1.8/1.9's Zend_Application and the resource system to initilize a bunch of resources. I would like to only load certain .ini files based on the module being requested – for example, loading "help.ini" if (and only if) the CMS module is requested ("/cms"). Trouble is, I'm not sure how to access the request object ...

Send forms to seperate pages for handling, or back to the same page?

Is it better to send an html form to a seperate page, or send it back to the same page?? i keep hearing to seperate logic from presentation, so I was wondering if I should seperate my forms from my form handlers as well. As of now, Im doing this... <?php if(isset($_POST['submitted'])){ //Validate the form if(empty($_POST['name'...

version control and deployment with eclipse?

I am working an a php webapp with eclipse as my IDE. I would now like to set up a version control system to manage my source code. I would also like to use the plugin to deploy my code live to the server. Can anybody recommend a plugin (subclipse?) and perhaps explain how I would use it to deploy my code? ...

array walk and replace in php or Javascript(phpjs)

<?php $frndof=array("name"=>'frnd_of_xyx',"id"=>001,"url"=>'tutorboy.com/frnd_of_xyx', "address"=>array("city"=>'NewZend',"zip"=>'100450')); $frndof1=array("name"=>'frnd_of_xyx1',"id"=>0011,"url"=>'tutorboy.com/frnd_of_xyx1', "frnds"=>$frndof,"address"=>array("city"=>'NewZend1',"zip"=>'100422')); $a = array( array("name"=>'xyx',"id"=>001...

Replacing keywords in a PHP script file using PHP

I have a PHP file with a mix of html, text and php includes name areaname-house.php. The text/html parts of the file contain the String "areaname" in various places. On the other hand I have an array of Strings with city names. I need a PHP script which can take each string (from strings array), copy the areaname-house.php and create a ...