php

PHP isset($this) and using the same object method in a static and object context

I'm working on a class which needs to be accessible via static function calls as well as object methods. One thing I have found is that I'm duplicating logic across multiple functions. Simplified example: class Configurable{ protected $configurations = array(); protected static $static_configurations = array(); public fu...

error using mysql escape string

What's wrong with my code, Im just a beginner. The error said it was an undefined index. A record is added to mysql but its just 0's. What' s the proper way of doing this $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Hospital", $con); $hospnum = ...

Is there any more lightweight portable PHP+Apache solution for wordpress development?

currently i'm using this XAMPP Lite 1.7.3 + Apache 2.2.14 (IPV6 enabled) + MySQL 5.1.41 (Community Server) with PBXT engine 1.0.09-rc + PHP 5.3.1 (PEAR) + Miniperl 5.10.1 + XAMPP Control Version 2.5.8 (ApacheFriends Edition) + XAMPP CLI Bundle 1.6 + XAMPP Port Check 1.5 + XAMPP Security 1.1 + SQLite 2.8.17 + SQLite ...

Get MySQL data without stressing server

I'm wondering what the best way is to prevent my server from being stressed when I want to get a lot of data using PHP. Convert all my data to an XML sheet? Use caching? The data comes from many different databases and different tables. Any ideas? Thanks in advance ...

PHP, XHTML and ampersands

How do I replace ampersands in a url from & > & I use some rss feeds witch has URL containing & should I use $link = str_replace('&', '&', $link); or there are other options? ...

Why is the MVC paradigm best suited for web applications?

I'm fairly certain my professor will ask me why I chose to use MVC for my web application. Truth be told, I'm new to MVC. I read about it, I'm building a blog application using it, I think it's very logical to approach a problem this way. But why? O_O I draw a blank. How is better suited than say, building an N-tier application? ...

<title> and window.parent

Hello, my site is a design on index.php and then a frame on it.. Now, i want to do so the titles changes When you browse to eg. Videos.php. So how should i do this with window.parent and title? The title needs to be changed on index.php. So cant it be done like on videos.php: <script> window.parent.changeTitle("Videos - Mysit...

help with regex match

i want to retrieve following urls with a regex: HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&amp;place=&amp;nation=&amp;english=Y&amp;subjectid=7009830" HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&amp;place=&amp;nation=&amp;english=Y&amp;subjectid=7009830&amp;ptype=PF" the difference is the ending. the first one omit...

php encrypt and decrypt

can anyone tell me how to encrypt and decrypt a URL string ? I want to encrypt a hyperlink ... ...

how to show unique array values in php

$content = '<h3>popular tags »</h3><hr>'; $result = $db->sql_query("SELECT tags FROM ".DOWNLOAD_TABLE." "); while($row = $db->sql_fetchrow($result)){ $dl_tags_id = $row['tags']; $dl_tags_id_ex = explode(" ",$dl_tags_id) ; $dl_tags_id = array_unique($dl_tags_id_ex); $c = count($dl_tags_id); for($i=1...

PHP: sorting out in a smart coding way?

Hello. So i have this videosection, but i want to make a "sorting" option avaible for users. Sorting Options: ALL (no WHERE in the sql statement), Videoklips (WHERE SCtry = 0), SC try (WHERE SCtry = 1) Now, i know how to do it "my" way. I would have placed links on index.php: ?sort=video and ?sort=SCtry Then make 2, if sort video, if ...

PHP Redirect by Browser Language not working!

I change languages using php arrays which makes the URL look like this: http://alexchen.zxq.net/index.php?lang=es I added $lang=$_SERVER['HTTP_ACCEPT_LANGUAGE']; in my 'controller' file in default sections, and I choose another language in the preferred languages option (Mozilla Firefox), but it didn't work. common.php: <?php sessio...

Firefox Upload Form Issue

Ive created an uplaod script in php that takes a file, resizes it, and creates a cropped square thumbnail. The script itself seems to work fine. However, when i tried to upload an image through firefox, on clicking the submit button the browser shows the loading animation, but it never calls the script, it just stays on the current pag...

Best way to echo HTML in PHP

I'm a fairly experienced PHP coder, and am just wondering what the best way of echoing large chunks of HTML code is (best practise). Is it better to do this: <?php echo "<head> <title>title</title> <style></style> </head>"; ?> or this: <?php define("rn","\r\n"); echo "<head>".rn ."<title>title</title>".rn ."<style></style".rn ."</he...

Double send of form when I refresh the page

How can I avoid to submit again the form when I hit refresh of the browser? Thank you. ...

Where do I create my layout in the Zend Framework?

In ASP.Net you'd create a MasterPage and have whatever pages use that. I need my pages to use the same basic layout. Where do I create it? ...

Transform my Flex application into Adobe Air. Running a PHP in Air

Hi, I'm a newbby in Adobe AIR/Flex. I have developed a simple Flex web app. that through 2 Php's, can connect to a DB and return an XML result of the query. I uploaded the PHP and Flex files to my internet server, and the app. works fine. My question is: How can I make the same app. work in Adobe AIR? In other words, I have made a new...

Wordpress: How to set default (active) theme via script

I need to assign the "active" theme via script. Anyone know the API call needed to do this? Also, how do I retrieve the current theme via script (PHP)? ...

Two quick question on transaction behaviour

I have code that looks like this: function foobar(array& $objects, $con = null) { if (is_null($con)) $con = DbSingleton::getConnectio(); $con->beginTransaction(); // <- question 1 try { foreach($objects as $object) { // allocate memory for new object $new_obj = new MyShiningNewObject(); ...

change initial array inside the foreach loop?

i want to have a foreach loop where the initial array is changed inside the loop. eg. $array = array('red', 'blue'); foreach($array as $key => $value) { $array[] = 'white'; echo $value . '<br />'; } in this loop the loop will print out red and blue although i add another element inside the loop. is there any way to change th...