php

How to extends use variable

$laca = 'laca'; class laca(){ /*Code*/ } class foo extends $laca; This code doesn't work. I want to make a DB class, and then have some DB driver : mysql, mssql v..v. $db = 'mysql'; So I want the DB class to extend mysql. Sorry for my bad English. ...

Pagination function

I'm trying to make a pagination script made by Jonathan Sampson (gotta give credit for his excellent video tutorials) into a function, so that I don't have to have to write it on every page I want pagination on, so I can use it all over my site without having pagination code on every page :) I thought I'd pass the query with the functio...

Call smarty plugin function directly from PHP

So I can use the Smarty plugin html_options within a template like this: {html_options options=$arr } But what I want to do is call the function behind this plugin (smarty_function_html_options) directly from PHP. I'm sure this must be possible, has anyone got any ideas on how to achieve this? ...

how to upload,play and store videos in a better way on my website

hello i am trying to making(just for knowledge purpose) a website similar to "you tube" and i am using LAMP(linux+apache+php+mysql). so please guide me on these topics(please keep in mind that the website is a high traffic web site like you tube): 1.i am taking video uploads from user using a simple form like: <form enctype="mult...

Update MySQL row automatic at change.

Hi! I got a kind of admin-panel where I want to be able to change customers order status live without refreshing or changing page. I have figured out that I need to use Javascript, AJAX or jQuery for this but since I have no experience for that and have no time to learn all that I'm asking you for help to achive this. My code: <form> ...

Background update via PHP??

I don't know if it is possible only with PHP but thought will ask here... I do have a PHP code which updates data every 15 days. my problem is when it updates the entire process taking more than 5 seconds so user must wait until the updates done. what I am looking is I want to do an background update while user is viewing the content. ...

Running php script and javascript onClick

I have the following line of code - <a href="/wordpress/wp-content/trackclicks/clickcounter.php?var=<?php echo $var3; ?>" onclick="return popitup2();">Grab Coupon</a> But suppose i want to redirect the current page to an external link and also run the php script and the javascript function.Is something like this possible - <a href="{...

PHP/MySQL Pagination with one query

The way I am doing my pagination now is as follow: =============== First I do the normal query, and get all the result back. After that I count the results, lets say 300. I do this with num_results Now I check what page the user wants, and the limit, lets say 30,10. Last I do the new query, with the limit selected. =============== ...

PHP login form on local site to access asp.net remote site

Is this possible? I want to have a PHP login form on my website. When the user enters a username and password and clicks submit, they should be directed to a remote website logged in (therefore skipping the login form on the remote site). As mentioned in the title, the remote site is built using ASP.NET. I've tried to search for a sol...

DBFactory, works only use static

-------Now, another question class DBFactory { static function create(){ return new MysqlDB(); } } class MysqlDB{ function alo(){ echo 'ok'; } } $db = DBFactory::create(); $db->alo(); --->Works class DBFactory { function create(...

Which PHP tags are always available?

Of the 4 types of PHP tags: Standard tag : <?php ...?> Short tag : <? .... ?> Script tag: <script language=“php”> ... </script> ASP tag : <% ... %> Which is/are always available ? ...

php code to check for repeating characters / bogus text

hi there, i'm running a dating site and there is a place where people enter their profile - I already have a bad-words filter but now I have a problem where people enter a profile that is just garbage characters or just "aaaaaaaaaaaaaaaaaaaa" or "--------------" etc. I'm looking for an effective way of filtering out the long words of rep...

verify, if the string starts with given substring

i have a string in $str variable. how can i verify is it starts with some word? example $str = "http://somesite.com/somefolder/somefile.php"; when i wrote the following script if(strpos($str, "http://") == '0') echo "yes"; //returns yes BUT it returns yes even when i wrote if(strpos($str, "other word here") == '0') echo "yes"; /...

Executing .jar file from PHP through Command prompt

Hi, I have a .jar file which has a command line interface. I want to call the jar file through command prompt and capture the output of the Jar file. I have tried with the exec() command. The command I have used is: <?php exec('java -jar D:\\Development\\Filehandler\\dist\\Filehandler.jar \ getConfigLang', $result); echo $result; echo...

Echo Return construct method;

<?php class DBFactory { function __construct(){ return 'Need to echo'; } } $db = new DBFactory; echo $db; ?> Not works :( ...

file_get_contents function not working

Hi All, I have some problem with file_get_contents() function, it not working properly when I tried to read URL like "http://google.com" is accessible but when I tried to access any file like "classes/connect_temp.txt" it is not accessible. Here is some code i use $file_path =realpath('./')."/classes/connect_temp.txt"; $...

PHP: What are language constructs and why do we need them ?

I keep coming across statements like: "echo is a language construct but print is a function and hence has a return value" "die is a language construct" My question is what are these language constructs and more importantly why do we need them? ...

Apache, PHP, MYSQL on Windows 7

What is the best (and easiest) way to set these up on Windows 7? I have tried Xampp and WAMP but all I get after installing them is a blank local host. So I create a php info file using the following code: <?php phpinfo(); ?> Put it in the httpdocs folder, call it using http://localhost/info.php and I get a 404 file not found erro...

PHP Calculations inside string creation

I want to to create a string in php, but within the creation of the string I want to do a small calculation, here is an example of what I am trying but does not work. $eggs = 2; $breakfast = 'I ate '. $eggs-1 . ' eggs for breakfast today!'; Using PHP like this gives me a unexpected T_CONSTANT_ENCAPSED_STRING error. ...

PHP filter_var for a URL against XSS attacks

Here is my function: function is_url($url) { return (preg_match('#^(https?):\/\/#i', $url) && (filter_var($url, FILTER_VALIDATE_URL) !== FALSE)); } And here is a nice url that it validates as true: http://blah.com"onclick="alert(document.cookie) Imagine if that goes into <a href="<?php echo $url; ?>"> Are there any better URL ...