php

How to get affected rows in previous MySQL operation?

mysql_affected_rows is to get number of affected rows in previous MySQL operation, but I want to get affected rows in previous MySQL operation. For example: update mytable set status=2 where column3="a_variable"; Before this operation, status of some rows is already 2, and I want to get affected rows in previous MySQL operation, you c...

How to use PHP include to insert an HTML stub across all pages in a website

Hi, I am developing a simple website. It will have close to 20 pages. It has a 3 level hierarchy. Home MenuStub Category1 Page1 Page2 Category2 Page1 Page2 .... .... .... The main navigation will have 4 - 5 items representing each 'category' This will be constant for all the pages. I am no...

Need little help with Mysql paging (LIMIT)...

I have this code: $page = $_GET['page']; $res_per_page = $_GET['res_per_page']; $start_point = (($page * $res_per_page) - $res_per_page); $query.= " LIMIT $start_point, $res_per_page"; $qry_result = mysql_query($query) or die(mysql_error()); $total_pages = ceil($nr_ads / $res_per_page); The variable '$nr_ads' ...

Singleton in Conjunction with the Factory Pattern in PHP5

What is the best method for using singleton design pattern in conjunction with the factory method pattern in PHP5? My simplest usage scenario for this is instantiation selective database connection only once for each database type. ...

Dynamic and static information in php (button appears after form instead of before)

I have a dynamic form that i am creating in php then i have a static button after that. However, the button is appearing on top of the dynamic form. The code for the button is simple, it is : echo "<input type=\"submit\" value=\"Click here\" /> </table></form>"; but i don't understand why does the button appear on the top of the...

Converting an eregi_replace to a preg_replace

I am trying to parse some HTML snippets and want to clean them up for various reasons (XSS et al). I am currently trying to remove all of the attributes on any tag, except for the href on a anchor. I am doing this using a sequence of eregi_replace calls, but I am sure there is a smarter way of doing this using preg_replace and just a c...

Decrementing the value of a variable

Is it possible to put this code $left_Nickels = 20; Inside any conditional and decrement the value of $left_Nickles? Or do I have to initialize to "". I want to be able to decrement the quantity of 20, which indicates the number of Nickels? That's why I don't want to start of by initializing to "", and then later on in a conditiona...

PHP & Regex : Adding website url to images

I have the following code below on my website. It's used to find the images in a block of html that don't have http:// or / in front. If this is the case, it will add the website url to the front of the image source. For example: <img src="http://domain.com/image.jpg"&gt; will stay the same <img src="/image.jpg"> will stay the same <im...

Sorting arrays numerically

I have a PHP array that I need to sort. I have included the example array below. I need to put the top 10 number of URLS plus their perspective counts in a different array. I know I could run into problem if there aren't 10 top matches ... if that happens then a random matching would be fine. Any suggestions? I have tried sort(myarra...

Faking method attributes in PHP?

Is it possible to use the equivalent for .NET method attributes in PHP, or in some way simulate these? Context We have an in-house URL routing class that we like a lot. The way it works today is that we first have to register all the routes with a central route manager, like so: $oRouteManager->RegisterRoute('admin/test/', array('CAdm...

Extend abstract singleton class

If you had a factory class that creates new objects of some kind, and that factroy class is a singleton, like this: class Database_Factory extends Base_Factory { private static $factory; private $objects = array(); public function __get($profile) { // check for object and return it if it's created before } ...

How to implement a service that can output formula with tex parameters?

Is there some open source project I can refer to? I'm using PHP. Anyone knows? ...

dpkg error exit status 2

Trying to build php from source on Ubuntu 9.10 to enable GD2, but when i run dpkg-buildpackage, it just quits giving me this error: QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null pop -a -R || test $? = 2 Patch suhosin.patch does not remove cleanly (refresh it or enforce with -f) make: *** [unpatch] Error 1 dpkg-build...

Error help in PHP

i have an eroor in sending data using textbox by POST to data base ERROR IS"NOTICE:UNDEFINED INDEX ON LINE" plz help me any one how can i solve this problem THIS IS MY CODE <?php error_reporting(0); $con = mysql_connect("localhost","root",""); mysql_select_db("hello", $con); $result = mysql_query("SELECT Max(id) as id from `aoa` WHERE...

How to store a list of users, and let the users know they are on that list

Im building a site where a user can add people to their "list". This list belongs to the user, but im wondering whats the best way to store/retrieve/loop through this list in a function, to show the people who are on the list, that they are there and who created it. So once the list of usernames is created, i would assume store it in a ...

how can I get data in the table cell that is checked after submit

can someone give me help, please. here's my basic html <form action="addSomething.php" method="POST"> <table> <tr> <th>Add Data</th> <th>Description</th> <th>Quantity</th> </tr> <tr> <td><input type="checkbox" name="data[]" value="sample1" /> </td> <td class="desc">Newbie</td> <td>2</td> </tr> <tr> <td><input type...

getting safe mode on although i turned it off

did a phpinfo to check which php.ini is being loaded. then i put safe mode off saved and restarted apache. i also put php.ini in the directory and used htaccess safemode off. htaccess safe mode off throws me a 500. in any case i am not able to disable safemode?! ...

Sending data to PHP scripts in the background from Cocoa

I have information I'm planning to sync between an iPhone application and a desktop application via a PHP script; is there a method of calling the script in the background to send data to the online database and then retrieve the data from the script? ...

Learning PHP and MySQL

Hi, I would appreciate if people can point me towards some good websites where I can learn PHP and MySQL for a complete newbie in these areas. I have the HTML, CSS and Javascript background but would like to venture out to PHP and MySQL. Any help would be appreciated. Thanks. ...

Question about a php switch

Given the array below, can I do this for the switch(use the variable $cost inside the switch)? Or does the switch($need a different variable here) $cost=array(chocoru =>1, oeenergy =>0.35, lemondew =>0.55, chcmyst =>0.25, drsalty =>0.75); Notice the $cost variable inside the switch is the same as the $cost associative array. switch(...