php

Events on PHP. Is it possible?

I'm coming from the C# world and has just started doing a little PHP coding, so I was wondering if it is possible to use events on PHP, or if it is planned to include this feature in a future release. If you have a way to simulate it, different than this, it would be very appreciated, thanks. ...

Sorting SQL row output per an arbitrary order?

So, in my database, I store musical instrument names (and various other attributes). Let's say id is the primary key, and name is a unique key. In a PHP script, I select items by their instrument class, like so: $name = mysql_real_escape_string($_POST['name']); $row = mysql_fetch_row(mysql_query("SELECT * FROM `instruments` WHERE name ...

Need help with wp_rewrite in a WordPress Plugin

Ok, I've got this code that I've been using to spit out news to an application of mine. It was working until today. I've cutout all the logic in the following code to make it simpiler. But it should "WORK" Can someone help me fix this code to where it works, and is done right? I know it's hacked together ,but it didn't seem to have ...

PHP F-PDF Scripting Possibilities

I need to know if there is a way to either a) Prevent a PDF from being saved to a client's computer (disable the save button) or b) Script the PDF to open, print, then close with no user interaction. I know this is a bit of a long shot, but I have to ask in case there is a way to do this. I am using F-PDF to create the pdf. Thanks ...

upgrade php to 5.2.12 on CentOS using yum

I tried to find a simple way to upgrade php on my centOS5 machine using yum instead of download the source and compile it again myself (I did it last time, but it's really difficult to get all the compile configurations same as CentOS's default). Anyway, I finally use the methods listed here: http://www.atomicorp.com/wiki/index.php/PHP ...

How to use TinyMCE custom button, with custom dialog, to add content?

TinyMCE editor lets you assign a custom button to it's editor toolbar. I did that and hooked it up to a Flickr account, so a custom dialog box appears with a selection of images. I want the user to be able to then click any image and have the URL of that image added to the original input, from where the custom TinyMCE button was clicke...

Composing a Controller class with Dependency Injection in PHP

How to solve the problem of composing a Controller class in PHP, which should be: easily testable by employing Dependency Injection, provide shared objects for end programmer provide a way to load new user libraries Look down, for controller instantiation with a Dependency injection framework The problem is, that derived Controll...

How do i get the SQL query ID after processing it?

Hi, This a bit looks complicated, i want to get the id column value of the processed query. example: $qu = mysql_query("INSERT INTO msgs (msg,stamp) VALUES('$v1','$v2')"); i want to get the ID of this query after storing the infos in database. if it's impossible, is getting the last ID record and adding 1 will be safe and guaran...

Pagination updating numbers

Hello, I am wondering if there is a possibility. I have a pagination script that grabs the content from a mysql database with php and using jquery to handle it all. I want to add a filter to the pagination which will get rid of some content based on the users selection. When the filter is set I would like the pagination numbers to upd...

PHP, then what? Oh, and also...OOP?

First Question - I've been "learning" PHP for about 3 years, but to be honest, I feel like I stopped learning it a while ago, so I want to start learning something new. I like web programming, and that's what I want to focus on, so I was wondering what the best/most useful language to learn would be. What language would I be best off kno...

jQuery Load an external script rich PHP file into local page

Hi guys, I've searched the entire web for a clear answer but haven't found one yet. I have this site: www.helixagent.com/todo/ and I want to load that entire site into a portlet in my main index page. I tried an iFrame approach but it fails to load the site correctly. The styles and javascript files don't get loaded (i think) Is th...

Browser closing and server question

How does the server knows that i've closed the browser in a code like this? <?php $i = 0; while (1) { echo "a"; flush(); $fp = fopen("$i.txt", "w"); fclose($fp); sleep(1); $i++; } ?> If i close the browser, the script stops and no more files are created. ...

Execute a XQuery with PHP

Hi, How to execute a XQuery in PHP? Can you give me an example? Thank you. ...

Picking a PHP MVC Framework

Hi, I have been a PHP developer for almost six years now, and during that time, I've written everything by hand. Literally everything. I'm now interested in learning more about MVC, and, as such, am interested in picking up a framework to play with. Before I go any further, let me just say that I know this question is subjective, and...

Giving PHP include()'d files parent variable scope

Is there anyway to for an included file to be used in a parent scope to the one it was called in? The following example is simplified, but does the same job. In essence, a file will be included by a function, but would like the scope of the included file to be the scope of where the function that included it was called from. main.php: ...

How to change from mysql to pdo using prepared statements in PHP?

$dml = "insert into bookmark(accountId,category,url,hash,title,created) value($_SESSION[accountId],$_POST[category],'$_POST[url]',md5('$_POST[url]'),'$_POST[title]',now())"; mysql_query($dml,$con); How do I do this statement using prepared statements in PDO? ...

Echoing a varied amount of variables into a varied amount of table cells

echo $s['name'] .": ". $result ."<br />\n"; That's my code echoing $sitename[] : $result[] Currently there are 3 sites that it echos. However I want it to echo it like so: <table> <tr> <td>$sitename[0]</td> <td>&nbsp;</td> <td>$result[0]</td> </tr> <tr> <td>$sitename[1]</td> <td>&nbsp;</td> <td>$result[1]</td> </tr> <tr> <td>$site...

SimpleXML returning multiple objects, how can I get the data?

I'm using simpleXML to parse this xml file. It's a feed I'm using to access the YouTube API. I want to embed the most recent video in an object and display the next four thumbnails. So I'm using simplexml_load_file on this, going using a foreach loop to access the values in each feed. I can access the values no problem, but I run into ...

MySQL Query in CodeIgniter with Session ID

Hi all, Let's say I have a query: " SELECT * FROM table WHERE donor_id = " .$this->session->userdata('id') ." GROUP BY rating" However, it appears that I get a mysql syntax error here, citing that $this->session->userdata('id') gives me '25' for example, instead of 25. Are there any workarounds here to prevent $thi...

section with nest array in smarty

Array ( [0] => Array ( [0] => SimpleXMLElement Object ( [0] => Pop music ) [1] => SimpleXMLElement Object ( [0] => Rock music ) [2] => SimpleXMLElement Object ( ...