php5

PHP shell command

Can anyone please tell me how to move file(s) into a dir in PHP? I did the following and it doesn't work. exec("temp/$file ../public/"); I would appreciate it. ...

PHP object cannot find method

Hello, So I have a very simple class that has a method called getThumbUrl() but when I try calling this method on an instance I get Notice: Undefined property: FlickrImage::$getThumbUrl But it is clearly there. Here is the code of the function inside of the FlickrImage class: public function getThumbUrl() { return "http://farm"....

php and mysql listing databases and looping through results

Beginner help needed :) I am doign an example form a php book which lists tables in databases. I am getting an error on line 36: $db_list .= "$table_list"; <?php //connect to database $connection = mysql_connect("localhost", "admin_cantsayno", "cantsayno") or die(mysql_error()); //list databases $dbs = @mysql_list_dbs($connec...

Is there any way to redeclare a class safely in PHP?

We all know the infamous "cannot redeclare class" error. Is there any method to overcome this and actually declare a new class with the same name, or is this impossible in PHP 5? ...

PHP constants declaration based on condition

I am using one separate file for all constants of my PHP application. class constants { const USERNAME = 'abc'; /* ⋮ */ } For lets say USERNAME constant, value can be either xyz or abc based on file exists check. If xyz file exists USERNAME value would be xyz. How can I do this check in my constants class? Thanks in ...

PHP endswitch; - Is this normally practiced?

I was reading some switch statements and noticed one using endswitch;. Why or why not should one use this? Is it even necessary? ...

Making a function for selecting from MySQL, how is mine?

This is my first time. I will appreciate any thoughts, tips, and what not. How can I improve this? Ultimately, I don't want so many selects in my script. I don't know what should a MySQL type of function consist of. Any inputs on what I should include would be great also, such as mysql_query(). function mysqlSelectCodes($table, $wh...

PHP MVC Framework Structure

I am sorry about the amount of code here. I have tried to show enough for understanding while avoiding confusion (I hope). I have included a second copy of the code at Pastebin. (The code does execute without error/notice/warning.) I am currently creating a Content Management System while trying to implement the idea of Model View Co...

libdb4.6-dev vs libdb4.7-dev

I want to install PHP 5.3 on Ubuntu Intrepid. To install apxs, I need to install libaprutil1-dev, which depends on libdb4.6-dev. When I look at installing that, apt-get wants to remove the currently installed libdb-dev and libdb4.7-dev. Any advice on how to proceed? [root@server:/usr/local] #> apt-get -s install libaprutil1-dev Readi...

create new db in mysql with php syntax

I am trying to create a new db called testDB2, below is my code. Once running the script all I am getting an error on line 7 Fatal error: Call to undefined function mysqlquery() in /home/admin/domains/domain.com.au/public_html/db_createdb.php on line 7 This is my code <? $sql = "CREATE database testDB2"; $connection = mysql_connect...

Passing along variable inside link works only on first word in multiple-word-variables, why?

I have this code below. As you can see I am passing two variables along with the link. The second variabye (category) works whenever it consists of one word, but some categories are two words or more, and then on the receiving php page where I fetch the variable only the first word is fetched. Any ideas? Example: I pass along this: Rim...

Access $Sesssion from helper in cakephp

hello folks. a cakePHP newbie here.... I have created a custom helper. I need to get a session value in this helper and i need to get some data from a table. How i can make these things possible. I have tried var $helper=array('Session'); but then also when i use $this->Session->read('userid'); it returns error Undefined pr...

What method should be used for searching this mysql dataset?

I've got a mysql dataset that contains 86 million rows. I need to have a relatively fast search through this data. The data I'll be searching through is all strings. I also need to do partial matches. Now, if I have 'foobar' and search for '%oob%' I know it'll be really slow - it has to look at every row to see if there is a match. ...

Using $this when not in object context--i am using the latest version of php and mysql

This is user.php: include("databse.php");//retrieving successfully first name and lastname from databse file into user.php class user { public $first_name; public $last_name; public static function full_name() { if(isset($this->first_name) && isset($this->last_name)) { ...

authorise user from mysql database

I suck at php, and cant find the error here. The script gets 2 variables "username" and "password" from a html from then check them against a MySQL databse. When I run this I get the follow error "Query was empty" <? if ((!$_POST[username]) || (!$_POST[password])) { header("Location: show_login.html"); exit; } $db_name = "testDB...

Using Solr and Zends Lucene port together...

Afternoon chaps, After my adventures with Zend-Lucene-Search, and discovering it isn't all its cracked up to be when indexing large datasets, I've turned to Solr (thanks to Bill Karwin for that :) ) I've got Solr indexing the db far far quicker now, taking just over 8 minutes to index a table of just over 1.7million rows - which I'm v...

PHP: How to implement a __get-like method for local function variables

I'm no stranger to __get(), and have used it to make some very convenient libraries in the past. However, I'm faced with a new challenge (PHP 5.3, abbreviated and simplified my code for this question): <?php namespace test; class View { function __construct($filename, $varArray) { $this->filename = $filename; $this...

working with arrays

I currently do a query which goes through the records and forms an array. the print_r on query gives me this print_r($query) yields the following: Array ( [0] => ( [field1] => COMPLETE [field2] => UNKNOWN [field3] => Test comment ) [1] => ( [field1] => COMPLETE [field2] => UNKNOWN [field3] => comment here ) [2] => ( [field1] => COM...

setting a cookie in php

I am trying to set a cookie, whas wrong with this as I am getting an error. Warning: setcookie() expects parameter 3 to be long, string given in /home/admin/domains/domain.com.au/public_html/setcookie.php on line 6 <?php $cookie_name = "test_cookie"; $cookie_value = "test_string"; $cookie_expire = "time()+86400"; $cookie_domain = "loc...

Implementing a configurable factory

I'm having difficulties finding out how to implement a 'configurable' behavior in a factory class in PHP. I've got at class, which takes another class as an argument in its constructor. The argument class could take a number of arguments in its constructor. An instance of my main class could look something like this $instance = new MyC...