php

how to use sql connection in PHP to execute a query on two databases

how can i run a query that joins two tables from TWO different Databases in mssql_query or mysql_query in php for example $conn=mssql_connect($ip,$username,$password); mssql_select_db("DB1",$conn); $q="select A.name,B.ID from DB1.dbo.T1 A, DB2.dbo.T2 B where A.ID=B.ID"; $res=mssql_query($q); how to run such query?? ...

PHP - why I could't declare static const variable?

I would use them to implement factory pattern, for example: class Types{ static const car = "CarClass"; static const tree = "TreeClass"; static const cat = "CatClass"; static const deathstar = "DeathStarClass"; } And I would like to use them like: $x = new Types::car; Is it possible? And what if my class has parametr i...

stoping javascript from getting executed

Hi, is it possible to prevent further execution of javascript? i include some javascript scripts with php in a header (with echo ''), but there are coming some other scripts later in the page which i can not always control, so it could be that my before included (with ) mootools javascript get later overwritten by another included moot...

PHP - preg_match - check if string contains year which is between 1950 and 2010

How do I check with preg_match if string contains year which is between 1950 and 2010 ? example: $string = "I was born in 1986 year."; ...

is any simple web project using cassandra and php available?

we are doing project using php and cassandra? if any already finished project using PHP and CASSANDRA available means that will help ful for reference. is there is any sample project available? and facebook uses cassandra. so how can we get some inputs from facebook experience and tools? is facebook maintain as opened? ...

Fatal error: Class 'ZipArchive' not found

I tried to unzip a zip file in my server using this code but doesn't work in my server <?php $zip = new ZipArchive; $res = $zip->open('Dolphin.zip'); if ($res === TRUE) { $zip->extractTo('dolphin/'); $zip->close(); echo 'ok'; } else { echo 'failed'; } ?> but im getting th...

Most effective way to create Excel files

Looking for a PHP solution to create Excel files on the fly (Think dynamic reporting). Now I have seen PHP Excel and I know I can create a CSV file but are these by best options? I running this script on a Linux system using PHP Excel but it doesn't set all the options $objPHPExcel->getProperties()->setCreator("Phill"); $objPHPExcel...

Setting variable and counting

$counter = ""; if($sWall>1){ $counter = $counter + $sWall; } if($sWC>1){ $counter = $counter + $sWC; } if($sOther>1){ $counter = $counter + $sOther; } if(!(empty($counter))){ echo "(".$counter.") "; } This is what I have that does not work. $sOther, $sWC, $sWall is mysql_num_rows. I wish to echo out e.g (3) if you have...

Multi-nested, multi-block mixins in lessphp

While transforming some code to lessphp from the classic less code; an incompatibility I discovered from the classic less css is that there is no support for multi-block mixins with nesting levels > 2. The classic less seems to be fully in support of mixins having many nested blocks in them. Is this intentional - the support for just tw...

Ajax or jQuery page reload with new data added to sql database

I'm totally new to ajax, but pretty good with PHP. I have a PHP page which currently refreshes every 2 minutes because it has to check for new data in the sql database. It's pretty annoying if you're using it and it keeps refreshing. The database is updated about 3 times a day, but what is shown on that page needs to be kept current with...

twitter search api not returning results

hi guys, i'm doing api calls from php backend like this: $term = "AT&T Park"; $q = '"'. urlencode($term) .'"'; $url = "http://search.twitter.com/search.json?q={$q}&amp;rpp=100"; $api_call = file_get_contents($url); it's not returning anything, but same api call working just fine on my terminal. here is a littl...

LAMP server on SuseLinux character set problem with Apache and php

Hi Guys I have installed LAMP server on suse linux on Amazon. Here is the server info Basic 32-bit Amazon Linux AMI 1.0 (AMI Id: ami-08728661) Amazon Linux AMI Base 1.0, EBS boot, 32-bit architecture with Amazon EC2 AMI Tools. I am trying to pass some special charters through a URL to PHP script but am not able to get it using $_GET['d...

How to echo a formatted date in PHP from an array

I have a datetime column in MySQL let's call it $time. It's coming form a CakePHP form. If I try to echo it I get I just get "Array". If I print_r() on it I get: Array ( [month] => 10 [day] => 30 [year] => 2010 [hour] => 16 [min] => 30 ) I want to echo this out as a formatted date, nothing seems to work because it's not a string bu...

PHP/Javascript: Making (1) in title as unread.

Hello, i have this: $counter = $sWall + $sWC + $sOther; if (!empty($counter)) { echo '(' . $counter . ')'; $counter = 0; } And js: $(window).blur(function() { tracktime = new Date(); setInterval(function() { $.ajax({ type: "POST", url: "imback.php", data: { mode: 'ajax', ...

How To: Upload text file and use with PHP script

Is it possible to achieve the following: Allow a user to upload a text file via HTML form (.txt) Use the contents of that file in a PHP script to temporarily access the information Delete any traces of the temporary file after the script has processed? Think of it as uploading a word document via html form, have a php script as basic...

Dynamic form fields in symfony 1.4

Hi there, I'm working on an e-commerce project and I got stuck at the cart update. Here I have to present a form using the contents of the current cart, with input fields containing the current quantities. I checked the documentation and the forums, but I didn't find anything useful. The problem is that i cannot declare the exact form ...

PHP accessing protected constructor

I know it is very uncommon to use protected methods or constructors. I have read discussions about this on SO and other sites. The task I've got is rather simple. I have to access protected methods/constructors from my program. All attributes/methods must be declared as protected. My code can be reduced to this. I'm basically asked to d...

Memcached installed but class not found

If I run phpinfo() it tells me that memcached is installed. memcached memcached support enabled Version 1.0.2 libmemcached version 0.44 Session support yes igbinary support no I installed it with sudo pecl install memcached But when I try to instantiate the memcached class it is not found: $mc = new Memcached(); ...

Storing values in PHP

I am trying to store values in php, like a HashTable with multiple keys. For example I am I would want this to return two different values: $value1=$content['var1']['var2']['var3']['typea']; $value2=$content['var1']['var2']['var3']['typeb']; What would be the best way to go about implementing a feature like this? ...

Best Practises on using Facebook-Connect in addition to your own authentification in your php application

I'm using the Kohana 3.x Webframework and I integrated Facebook-Login successfully. That means: the user can click on the Facebook-Login-Button, I get the fbs_ Cookie and I can query facebook for all the information i need (like name, friends, etc...). I believe that I can trust facebook and their security so I just get the facebookid ...