php

Loading page all content and scripts inside another

If you go to this page on our website: http://www.divethegap.com/scuba-diving-programmes-dive-the-gap/dahab-divemaster-training.html The buttons at the bottom that say 'Beginner' 'Open Water Diver' etc.... They take you to another page where you have a series of options and can book. We would like it so that rather than have to navigat...

PHP MySQL query

What is wrong in this code? $sql = "SELECT * FROM blogs WHERE blog_id = $'blog_id'"; $result = mysql_query($sql); $rows = mysql_fetch_array($result); $content = $rows['blog_content']; echo $content; The error is : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\jo...

Why are configuration arrays acceptible parameters in PHP and Javascript?

In most other OO languages it would be sacrilege to have each function receive a single associative array of Objects rather than enumerating each in the method signature. Why is it acceptable and commonly used in most popular frameworks for both of these languages to do this? Is there some justification beyond wishing to have concise m...

Question about [literally] mapping location based on an IP address.

I've been bored lately and I want to start a new project. I was looking at a website mentioned in a different question (http://www.grapevinegame.com/), and I thought the map and how it plots a point based on someone's IP (I assume) is pretty nifty. I want to do something like that, but I have no idea how it's done. I know you can get lat...

URL Rewrite problem. (Many directory)

Hello! I'd like to make a htaccess file, which can make a good structure for my websites. My .htaccess is now: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|txt)$ RewriteCond %{REQUEST_URI} !/admin RewriteRule ^(.*)$ index.php?q=$1 [QSA] (based on Sombat's comment, and about 30 try :P) And I want t...

form element added uisng jquery not recognised by $_POST

<script type='text/javascript'> $(document).ready(function() { $("#specific_consultant_yes").click(function() { $('.specific').show('slow'); $.post("<?php echo $this->url(array('controller'=>'appointment', 'action' =>'available'),'default',true)?>",{app_date:$("#App_date").val(),consultant:$("#Consultants").val()} ,function(data){ $("...

Searching a keyword in a long string in mysql?

Hello keyword = house SELECT * FROM products WHERE description LIKE '%house%' This query also returns records having keyword, for example, courthouse, but I want to look for house only. How do I search anywhere in the description for "house" only? Thanks. UPDATE just for more clarification .. actually house, can be at - the...

PHP gettext: not all strings becomes translated

I have these two adjacent lines of code: <td><?php echo __('Product', 'wpsc'); ?>:</td> <td><?php echo __('Quantity', 'wpsc'); ?>:</td> And these translations in the .po file msgid "Product" // Translates msgstr "Produkt" msgid "Quantity" // does not translate msgstr "Antall" One string shows up translated on the webpage, the o...

PHP sorting an array by mysql date.

Hi I have an array that I would like to sort using a date field from a MySQL database. Here is a sample of the array which is named news in my class: [48] => Array ( [id] => 14 [type] => 3 [updated] => 2010-04-17 13:54:42 ) [49] => Array ( [id] => 15 [type] => 3 [updated] =...

Which MySql line is faster:

I have a classified_id variable which matches one document in a MySql table. I am currently fetching the information about that one record like this: SELECT * FROM table WHERE table.classified_id = $classified_id I wonder if there is a faster approach, for example like this: SELECT 1 FROM table WHERE table.classified_id = $cla...

How to split records per hour in order to display them as a chart?

Hi, I have an SQL table like this : sales(product,timestamp) I want to display a chart using Open Flash Chart but i don't know how to get the total sales per hour within the last 12 hours. ( the timestamp column is the sale date ) By example i will end up with an array like this : array(12,5,8,6,10,35,7,23,4,5,2,16) every number is the ...

PHP mysqli Insert not working, but not giving any errors.

As the title says Im trying to do a simple insert, but nothing actually is inserted into the table. I try to print out errors, but nothing is reported. My users table has many more fields than these 4, but they should all default. $query = 'INSERT INTO users (username, password, level, name) VALUES (?, ?, ?, ?)'; if($stmt = $db -> prep...

PHP - HTML Purifier - hello w<o>rld/world tutorial striptags

I am just looking into using HTML Purifier to ensure that a user-inputed string (that represents the name of a person) is sanitized. I do not want to allow any html tags, script, markup etc - I just want the alpha, numeric and normal punctuation characters. The sheer number of options available for HTML Purifier is daunting and, as far...

Styling an If Else Statement

I know that it's not possible to style any given PHP but I do know that it is possible to style the output HTML that the PHP provides you with. I was wondering if there was any method available for me to use that would enable me to style the output from my IF ELSE statement. if ($result != false) { print "Your entry has successfully...

why won't my ajax work asynchronously

I'm having trouble understanding why my code will not work asynchronously. When running asynchronously the get_price.php always receives the same $_GET value even though the alert before outputs a unique $_GET value. var arraySize = "<? echo count($_SESSION['items']); ?>"; //get items count var pos = 0; var pid; var qty; getPriceAjax...

CakePHP Permissions, works fine on local server, but fails after upload.

I created a website with CakePHP, set up all of the permissions so guests could view certain parts, and members only in certain areas, all with an administration panel. Whenever I test this on my local testing server, it works perfectly, if I login I can view the content, if I logout, I can't. However, when I upload exactly the same f...

why this sql not working?

I have a query public static function TestQuery( $start=0, $limit=0){ $sql = " SELECT count(*) AS total FROM db.table1 JOIN db.table2 ON table1.fieldID = {$fieldID} AND table2.assigned = 'N'"; $qry = new SQLQuery; $qry->query($sql); if($row = $qry->fetchRow()){ $total = intval($row->total); } ret...

Magento 1.4 Load By Category Not Working

Hi folks. I have a Magento helper class I wrote that works wonderfully in 1.3. However, we're working on a new install of 1.4 and filtering by category won't work for some reason. function __construct() { Mage::app(); $this->model = Mage::getModel('catalog/product'); $this->collection = $this->model->getCollection(); $this->...

Output custom messages based on row value

I've made a simple guestbook mysql/php page. An entry is displayed if the approve column has a value of 1. For the adminstrator, I want to display either "message approved" or "not approved". Here's my code: while ($row = mysql_fetch_array ($r)) { print "<p>Guest:" .$row['name']. "</p> <p>Date:" .$row['date']. "</p> ...

PHP - why is this date function not erroring out

function convertDT($TS) { $TS = strtotime($TS); $TS -= date("Z"); $newTS = date("Y-m-d\TH:i:s\Z", $TS); return $newTS; } echo "Good: ".convertDT('2010-04-20 01:23:45')."\n"; echo "Bad: ".convertDT('2010-31-20 01:23:45')."\n"; The second date returns: 1969-12-31T23:00:00Z Why? Should this error? ...