php

how to add a new php file to mvc concept

how to use the mvc concept, i need to add a php file to mvc concept. please explain ...

Break method chaining in php

Hi I am using method chaining for my class structure. So my problem is that , how could i break my chain when error occurred in some function. Below is my code: <?php class demo { public __construct() { $this->a='a'; $this->b='b'; $this->error = false; } p...

Using PHP with a MySQL db, how can I select everything from a row if i dont know what the columns are?

I have a table but I dont know what the columns are except for 1 column. There is only 1 permanent data value for each row, the rest of the columns are added and removed elsewhere. This isnt a problem for the query, i just do: SELECT * FROM table but for the php function bind_result() i need to give it variables for each column, which...

How to edit an array's key?

Is it possible to edit the key once it has been made? I know you can create an array with a different key but I couldn't see anything on the php site about editing the key latter. Original array: Array ( [0] => first [1] => color ) What I would like: Array ( [newName] => first [1] => color ) ...

Why isn't this easy join working? (mysql)

I have two tables, classified and fordon. classified table: classified_id (PK) etc... fordon table: id (PK) classified_id (FK) I try to use this code: SELECT * FROM classified, fordon WHERE classified.ad_id IN ('$solr_id_arr_imploded') AND classified.classified_id=fordon.classified_id BTW, the array is a set of ad_id:s returned fr...

Best way to avoid duplicate entry into mysql database

I have a table with 3 columns - id (pk), pageId (fk), name. I have a php script which dumps about 5000 records into the table, with about half being duplicates, with same pageId and name. Combination of pageId and name should be unique. What is the best way to prevent duplicates being saved to the table as I loop through the script in ph...

Retrieve Image from postgres database using PHP

I am working in PHP with Postgresql as backend. The database is already designed by others. Now I want to retrieve image from the database using PHP. But I'm not able to retrieve image from the database. I using this code to retrieve image but it shows only unreadable characters in the webpage. Sometimes it shows a small icon (like when...

PHP Request Form - I am not sure how to use it

Hi There I am hoping that there is someone that can help me with this question. I am a ASP programmer and not sure how this works in PHP echo '</textarea> <input type="hidden" name="g_word" id="g_word" value="$_POST[g_word]" /> <input type="hidden" name="article_no" id="article_no" value="$_POST[article_no]" /> </form...

Getting PHP to run a Python script

Hi all, I am trying to run a Python program using PHP. Here's the code $command = '/usr/local/bin/python script.py file'; $temp = exec($command, $output); This works through the command line but not while running it through the browser. I am using Apache so probably it needs the right privileges? I am pretty new to Linux and have no i...

CakePHP ACL confusion, how do I apply ACLs to objects, not actions?

Can anyone suggest a scalable design pattern for implementing access control on Photos and Albums, each with individual privacy settings (i.e. owner, group member, public)? I'm using CakePHP, and the examples I have read on the ACL component seem to control access to controller/actions, not objects themselves. It seems to get out of ha...

Problem with addDisplayGroup in the Zend Form

Hi all, I have a form same the following code: public function init(){ $id=$this->createElement('hidden','cf_id'); $id->setDecorators($this->elementDecorators); $id->setOrder(1); $this->addElement($id); $firstName=$this->createElement('text','firstName'); $firstName->setDecorators($this->elementDecorators); $firstName-...

Understanding large mysql data relations

I am trying to teach myself how to use SQL, namely mysql. What I am trying to understand is how to deal with many different types of data with in the same table. Say I am building a web application, and I have many different content types (blog item, comment item, files, pages, forms) that I need to store different data fields for each...

Changing the browser back button to go back twice

Hi, I have this web application which does the following as standard to all websites Users browse to any page on the website They click on login link on header from any page Visit login page and then login and get directed to their logged in page IF user then hits back button they get to login page and that redirects to home (because...

connect PHP with postgreSQL8.3

Hi, I was trying to connect my PHP page to PostgreSQL, but it's not working. The code which I have tried is given below: <?php $connection = pg_connect("host=localhost dbname=mydb user=postgres password=pgsql"); if (!$connection) { echo "Couldn't make a connection!"; } ?> During the time of installation, the system aske...

Any way to "follow" PHP headers?

I'm having a problem where my script is redirecting to a location using header(). However, it's a headache to debug this since I have so many functions that send headers. Is there any debug feature in PHP that allows me to follow the headers? Thanks ...

How to interact with PHP via getURL in actionscript?

getURL('http://www.google.com',_blank); The above can open google.com,but how to fetch data from server side(PHP) on localhost? ...

PHP session starter detect for visitor counting

Is there a way to find out on session being started. Like for instance the session start event in the global.ascx file of .net. The requirement is to find the no. of visits the user has done on the site. Instead of checking each time during posts or gets to the server. Is there something in php to find out if the session is a new one. ...

What's better of require(dirname(__FILE__).'/'.'myParent.php') than just require('myParent.php') ?

Lots of famous PHP scripts including WordPress use dirname(_FILE_).'/myParent.php' instead of just 'myParent.php' when including files in the same directory of the currently running script. Aren't they the same thing? Why do you prefer typing more? Thanks. ...

PDO mySql query not executing in for loop the second time up while calling

I have an issue, I'm looping threw a set of values and then creating a PDO mySql query with every loop, now the problem is the first query is executing and returning results, but the second upwards aren't returning results. If I manually execute the queries on the server they return results. This is weird, maybe I'm doing something wrong...

In php, is 0 treated as empty?

Code will explain more: $var = 0; if (!empty($var)){ echo "Its not empty"; } else { echo "Its empty"; } The result returns "Its empty". I thought empty() will check if I already set the variable and have value inside. Why it returns "Its empty"?? ...