php

javascript function from php

Dear all, I have a javascript function pop_item I have to call this from PHP, so my PHP code is the following: echo '<a href="javascript:pop_item('.$_code.',1)">Link </a>'; It provides no error, but pop_item is not functioning, The HTML output for the above is: <a href="javascript:pop_item('ABC',1)">Link <...

phpunit warning on an utilitary class

Hi, I use phpUnit on a integration server to run all tests and if I lauch phpunit command from the command line, I receive PHPUnit 3.2.18 by Sebastian Bergmann. F..III..I......I.IIII... Time: 6 seconds There was 1 failure: 1) Warning(PHPUnit_Framework_Warning) No tests found in class "TU". FAILURES Tests: 24, Failures: 1, Incomplete: ...

PHP ignoring mysql_connect requests

I'm new to PHP and have installed on Linux to boot (also a newbie). Anyway, PHP is working... <? $myVar = "test"; echo($myVar); ?> ... works just fine. But... <? $dbhost = "localhost"; $dbuser = "myuser"; $dbpass = "mypass"; $dbname = "mydb"; echo($dbhost . "-" . $dbuser . "-" . $dbpass . "-" . $dbname); $conn = mysql_connect($db...

Call a function before outputting headers in PHP?

Is there any way to have PHP automatically call a function, before a script outputs any HTTP headers? I'm looking for something like register-shutdown-function, but to register a function that's called before the output is already sent, not after. I want my function to send a header, so I need something that's called earlier. ...

Refactoring To Remove Static Methods Code Smell

I have the current basic structure for each domain object that I need to create: class Model_Company extends LP_Model { protected static $_gatewayName = 'Model_Table_Company'; protected static $_gateway; protected static $_class; public static function init() { if(self::$_gateway == null) { self::...

Passing Value to Javascript from Php

Dear all , I have php code of the following <?php echo "<SCRIPT LANGUAGE='javascript'>add dd_Employee('".$id1."','".$fname1."',".$sal1.");</SCRIPT>"; echo "<SCRIPT LANGUAGE='javascript'>add dd_Employee('".$id2."','".$fname2."',".$sal2.");</SCRIPT>"; .... ?> ... And My javascript Code Contains var details=new Array(); function...

Good PHP hosting options?

Surprisingly, it seems this question hasn't been asked yet (or at least I couldn't find it). I'm after a "good" PHP hosting solution. Obviously "good" is a subjective term, so I'll provide some guidelines: Scalable solutions from cheap shared to dedicated with easy transition between them (ie a smooth and relatively painless upgrade ...

how to prevent PHP's file_get_contents( )

one of my php page returns data like this: <?php //... echo "json string"; ?> but someone else use file_get_contents() to get my data and use in other website. can anybody tell me what can i do to prevent such thing happen. i consider if i can get the request's domain name to echo something else.but i dont know the function t...

Is Symfony a better choice than Zend for a web development shop (10+) because it is a full stack framework?

My team at work is considering to use a framework for developing web sites and applications. Some of the seniors are convinced we should use the Zend Framework because it is easier to pick-and-choose the features so the framework we will be light-weight. I'm afraid however that they are only looking at the technical advantages that a l...

Using parent variables in a extended class in PHP

I have 2 classes, main and extended. I need to use main vars in extended class. <?php class Main { public $vars = array(); } $main = new Main; $main->vars['key'] = 'value'; class Extended extends Main { } $other = new Extended; var_dump($other->vars); ?> Who I can do it? No valid for example: <?php class Extended extends Mai...

What are the Facebook app FBML 'profile.setFBML' arguments?

Okay so I've read the documenation: http://wiki.developers.facebook.com/index.php/Profile.setFBML And I'm not quite sure what the arguments being passed are. I'm looking at the the listed example request: $facebook->api_client->profile_setFBML(NULL, 128009, 'profile', NULL, 'mobile_profile', 'profile_main'); and thinking, where are th...

Auto accepting contacts using phpmsnclass

Hello I'm currently using phpmsnclass to send messages to contacts on the MSN network. But to get the nickname on my "bot" to work I have to accept the "friend-request" my contacts has sent me. From the debuginfo I have found that around line 1672 in the file msn.clas.php it's a kind of auto-accepting feature. But I cant use the doLoop ...

Best way to transfer an array between PHP and Javascript

So I have an array of records retreived from a database. The array is in the format; $rows[0]['id']=1; $rows[0]['title']='Abc'; $rows[0]['time_left']=200; $rows[1]['id']=2; $rows[1]['title']='XYZ'; $rows[1]['time_left']=300; //And so on upto 10-20 rows What's the best/most elegant way of transferring this array over to my javascript...

PHP UML Generator

How do I generate UML diagram based on existing classes in PHP? ...

2 Column Mysql Date Range Search in PHP

Hello.. MySQL column > sdate, edate ( its 2 column). sdate is start date for project starting and edate is end date for project ending. so i need to make search between them.. <strong>Search</strong><br /> <form method="post" action="search.php"> Start Report Date : <input type="text" name="sdate" /> End Report Date : <input type...

Delphi for PHP - location of source

I just installed Delphi for PHP to get an idea on how it works and have created a simple app with a button that puts a text into a listbox when it is clicked. The app works if I copy all required files to my webserver and run it from there. It also works if I save the project in the standard path: "c:\documents and settings\username\My D...

Regular Expression to Detect a Specific Query

Hi, I wonder if you anyone can construct a regular expression that can detect if a person searches for something like "site:cnn.com" or "site:www.globe.com.ph/". I've been having the most difficult time figuring it out. Thanks a lot in advance! Edit: Sorry forgot to mention my script is in PHP. ...

Ensuring MySQL connection works in PHP function

I have code with the following form: <?php function doSomething{ //Do stuff with MySQL $con->tralalala(); } $con = connectToDatabase;//This would actually be a line or two. doSomething(); ?> This (type of) code doesn't work, because doSomething() doesn't have a connection to the database. Can anyone explain why not? I create the...

Searching for a Kohana Beginner's Tutorial for PHP

I am going to try to build a PHP website using a framework for the first time, and after some research here and there, I've decided to try to use Kohana I downloaded the source from their website, and ran the downloaded stuff on my web server, and was then greeted with a 'Welcome to Kohana!' page, and nothing more... I've tried to find...

a "forgot user password" standard class or script in php/mysql environment?

Hi, I am hoping that there is a standard class/php script that we can use for the "forgot password" functionality. It seems almost every website has one, and I'd like to reduce the development time on it. It appears that a common approach is: 1) click on Forgot password 2) User receives via email a "reset password" link 3) Click on th...