php

What does this Regular Expression Mean

$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); And is there any place I can learn regular expressions? I know the basics. ...

Help with a MySQL query, selecting a maximum element

I have a table with 4 columns: place_id, username, counter, last_checkin I'm writing a check-in based system and I'm trying to get a query that will give me the "mayor" of each place. The mayor is the one with most check-ins, and if there is more than 1 than the the minimum last_checkin wins. For example, if I have: place_id, username...

Select MYSQL rows but rows into columns and column into rows

I want to select all the rows in my database but I want them in inverted sequence. Meaning, I want to use the first column data as the new entities and present entities as the first column. I think you got what I mean Here is an illustration id | name | marks ------------------------------- 1 | Ram | 45 ----...

A few questions regarding $_SERVER['HTTP_USER_AGENT'] and using RegEx to extract information from the results

Okay, take this user agent for example: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Curious as to what all of it means. I can figure out a few things, obviously, such as Mozilla == Firefox, and Windows NT 5.1 == Windows XP. But what is the rv:1.9.2.6, and What is Gecko? and U? And also, I'm working on se...

How to select different columns from database each giving the sum(or similar) of another query result?

Here is sample query SELECT name, sum(SELECT id FROM mytable WHERE cond='1' and cond2='2') as mysum1, sum(SELECT id FROM mytable WHERE cond3='3' and cond4='4') as mysql2 FROM mytable WHERE userid='1' and status='1'; Obviously this does not work but I think you can now understand what I mean. How to retrieve ...

How to use mysql dump in php

I've tried using mysql dump in the command line and it worked. How do I do it in php? I found this code from the internet, and tried it. <?php ob_start(); $username = "root"; $password = "mypassword"; $hostname = "localhost"; $sConnString = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $conn...

How to append or replace trailing question marks using preg_replace?

I want to enforce single question mark at the and of the string. In JavaScript it works perfectly: var re = /[?7!1]*$/; document.write('lolwut'.replace(re, '?')); document.write('lolwut?'.replace(re, '?')); document.write('lolwut??'.replace(re, '?')); document.write('lolwut???'.replace(re, '?')); document.write('lolwut???!!!11'.replace(...

How to convert MM/DD/YYYY to YYYY-MM-DD?

Hi all, I have a jquery calendar that sets the input value to MM/DD/YYYY How would I convert it so that my database column (date) can accept it correctly? EDIT Gordon was right - his link pointed me to this answer $mysql_date = date('Y-m-d H:i:s', strtotime($user_date)); ...

Display Menu Title in Drupal please

I have a custom menu in Drupal. Here is the code I use to display it inside my theme (page.tpl.php): <h4>Site Information</h4> <?php print theme("links", menu_navigation_links("menu-teaser-05")); ?> Rather than display Site Information I would like to be able to pull out the Menu Title. Short of doing custom SQL/code can anyone help...

Simulate a click with CURL (PHP)

Hi everybody, I'm using CURL to extract some real estate listings. But, recently, a website changed his way to communicate the phone number: The visitor must click on a "Show the phone number" link that returns the result in jSon. I found these information with Firebug: http://www.realestate.com/phone/click.json?Id=023DSFS And for th...

Setting the AUTO_INCREMENT of userid

guys, how can i set the auto_increment of my userid something like this: i want to start it in 200, then increment by 10 with a maximum value of 1000.. how will i code it using php? please help me.. :-( ...

Parse error when concat'ing a defined variable and string in a class!

Hi guys, I have defined a variable in a separate config file: define('URL', 'someurl.co.uk'); However, when I try to use it to concat with a string inside a class: class AdminEmail extends Email { private $from = "jsmith".URL; I get the following error: Parse error: parse error, expecting `','' or `';'' But if I echo it ou...

PHP: Need a opposite method of timezone_name_from_abbr?

I need an exactly opposite method of timezone_name_from_abbr(): http://php.net/manual/en/function.timezone-name-from-abbr.php I have a list of timezones name like: Australia/Brisbane Australia/Hobart Asia/Vladivostok Australia/Lord_Howe Asia/Magadan Asia/Kolkata America/Los_Angeles ...... I need method which will take timezone as a p...

Browser requests for images

I've been doing some experimenting with php and html, and I'd like to know if it's possible for the browser to send a separate request for multiple images that have the same file name. For example, if I had <img src="showimg.php?id=1234"> written out 3 different times, is it possible for the browser to send the request 3 different t...

Anybody knows how to use Zend_db component with oci8 in Zend framework?

I am going to use Zend framework to access data from an oracle database. Previously I have the class I built to interact with the database (outside of framework), those are all procedural and function calls in the database (not SELECT statements), I have to bind variables and then execute them. I am looking to use Zend_db component to ac...

How to rewrite this php function into HTML-emeddable function <?php ?>

Could someone convert this line of code to be readable by HTML? echo '<h3>'. $r['title'] .'</h3>'; into something like this: <?php echo...blah blah blah ?> /* To display the title in HTML */ I am sure I am not doing it right, that's why it's still not working :(. Edit: There seems to be a confusion here. I am not going to mod...

Best and fastest way to place items on a Google map with PHP

Hello guys, For the project I'm currently working on I have a database with locations (restaurants, hotels, coffee shops etc.) and I have to place each one on a map. For each location I have its name and full address. What is the best and fastest way to accomplish this using Google Maps? I'm using PHP. Thanks. ...

Load Javascript array with MYSQL database data

Hello, suppose i have an javascript array "userName".I want to load it from a database table named "user". Can anyone help with idea or sample code? Thanks ...

How to create custom forms for custom content type in wordpress?

Hi.. Is there any way to create forms for a particular content type and submit it form the site itself. I have 2 content types created in my Wordpress and I want to create a form to post to a particular content type. Also is it possible to create the form as a page in wordpress? regards - dj ...

How to add a custom class to all drupal anchor elements

Hi, I'm new to Drupal and have been looking for a way (function or template method) to add a custom class(html attribute) to ALL anchor elements of the drupal site. I want to manipulate the anchors with jquery and need to be able to remove this class later on. Thanks ...