php

How can I Display an extract from MySQL database entry?

I'm after creating a webpage that includes a blog section and it currently displays the whole post on the homepage. I'd like to set it so that it only displays a certain part of the entry i.e 50 words. I'd then like to be able to set it so that I have a read more button below the post that links to the post id. I currently use post.php?=...

How much PHP do I need to know to design wordpress themes

So I want to start developing Wordpress themes, but I don't know PHP. How much knowledge should I have of PHP before I begin Wordpress development? Can anyone recommend any PHP books? ...

Database Design and Performance : mySQL and PHP

I have made an image for this question: What is the right design? All site's block inserting in only one table or separate tables? Thanks in advance ...

PHP: preg_replace() with pattern modifier e - strange behaviour in evalution result seems to ignore back references

Consider the following situation: I want to replace links in a string, specifically I want to add a "search engine" link next to it. Think: Link Title (S), where as S will link to Google with "Link Title" as search term. I've copied a real life example string ($content) in the code so you can reproduce this 1:1 in PHP code. // PCRE cas...

PHP PCRE expression problem - get digits of a string

Hi, I need a regex expression (PCRE) to match a integer number inside a string, being the string like : image89.jpg I've tried many options without success. I'm using preg_replace() by the way My last attempt : preg_replace('(\d+)', '$1', 'image89.jpg'); ...

Easiest way to access SOAP web service if I've SOAP envelope ready?

I've a complete SOAP envelope (XML) ready. What would be the easiest way to send this envelope in php? I know about SoapClient and Zend_Soap_Client but please consider this particular case, where I just want to send this envelope and print the xml response. //Pseudo function for what I wanna do public function sendEnvelope($xmlEnvelo...

MySQLI Prepared Statement Not Binding Properly

Any reason why the following code won't work? $dbconnection = db::getInstance(); //this is a singleton db class $stmt = $dbconnection->prepare("SELECT `id` from `table` where `username`=?"); $stmt->bind_param("s", $username); $stmt->execute(); $stmt->bind_result($uid); $stmt->fetch(); echo $uid; The same connection method is used e...

jQuery does not return a JSON object to Firebug when JSON is generated by PHP

The contents of test.json are: {"foo": "The quick brown fox jumps over the lazy dog.","bar": "ABCDEFG","baz": [52, 97]} When I use the following jQuery.ajax() call to process the static JSON inside test.json, $.ajax({ url: 'test.json', dataType: 'json', data: '', success: function(data) { $('.result').html('<p...

Extract information from javascript counter via PHP

Hi, I'm looking for a way to extract some information from this site via PHP: http://www.mycitydeal.co.uk/deals/london There ist a counter where the time left is displayed, but the information is within the JavaScript. Since I'm really a JavaScript rookie, I didn't really know how to get the information. Normally I would extract the ...

User role permissions for different modules using bitwise operators

So I have an application that has several modules (think of modules as different pages), each module has a set of permissions; view, add, edit, delete I want each user role to have privileges for each module, for example Role A Permissions Module 1 -> view Module 2 -> add, edit Module 3 -> view, add, edit, delete etc. H...

Help with making an SQL query based on some rules

Hello there. I've got this HTML form where I have multiple input elements: text, radio, and so on. These are intended to be options, conditional items to apply in an SQL query in order to pull more specific data from a database. For example, the first input field is a textbox, the second a radio button, and the third a SELECT with two ...

wordpress query custom fields and category

I have a query that creates a table view and then another that queries the view. The results are extremely slow. Here is the code: create or replace view $view_table_name as select * from wp_2_postmeta where post_id IN ( select ID FROM wp_2_posts wposts LEFT...

clever way to conditionally split this string?

I've got a string that could be in one of two forms: prefix=key=value (which could have any characters, including '=') or key=value So I need to split it either on the first or second equals sign, based on a boolean that gets set elsewhere. I'm doing this: if ($split_on_second) { $parts = explode('=', $str, 3); $key = $par...

Create a PHP cache system in MySQL database?

I'm creating a web service that often scrapes data from remote web pages. After scraping this data, I have a simple multidimensional array of information to use. The scraping process is fairly taxing on my server, and the page load takes a while. I was considering adding a simple cache system using a MySQL database, where I create one ro...

php with two class

Hi Guys, my sample is good or not? I have a good connection to the database, or too should be in the class? Thanks <?php mysql_connect('localhost','root','admin'); mysql_select_db('test'); class UserDisplay { function getDisplayName() { $sql = 'select first_name, last_name, display_name from users where user_id = "3"'...

include and Get not working on index

I have a problem with my index.php, i have this small script that decides what content to deliver <?php $clase = $_GET['clase']; if ($clase == empresa) {include ("empresa.php");} elseif ($clase == productos) {include("productos.php");} else {include ($_SERVER['DOCUMENT_ROOT']."/inicio.html"); } ?> it works when i go to www.mys...

I'm still learning OOP. Any tips on staying unbiased and pragmatic?

I keep reading about defficiencies and issues with languages. Specifically, I'm learning PHP and Javascript, but I see it everywhere. This question arose while reading Javascript: The Good Parts and PHP Objects, Patterns and Practice. While understanding and avoiding easy pitfalls, is there a way I can learn the fundamentals of OOP and d...

Search MySpace by keyword using PHP class

I've come across several tools that search users by keyword, however, none that's open source. I'm not familiar with the MySpace API and at first glance it doesn't seem like this option is available. I was hoping a PHP class exists for this sort of thing. So my question: how do I identify myspace users that have a keyword? Can it done ...

Least intensive way to find all nested subcategories using mysql query

I have a database in which items are placed into categories. Some of these categories are nested, so as an example: Animals > Birds > Parrots Animals > Birds > Penguin Animals > Mammals > Cats Animals > Mammals > Dogs Animals > Reptiles > Snakes Plants > Trees Plants > Flowers etc I have these in a table along the lines of ...

Are sessions modifiable by the client/user?

In my PHP Web-App I use sessions to store the user's data. For exmaple, if a user logs in, then an instance of the User class is generated and stored in a Session. I have access levels associated with each user to determine their privileges. Store the user in a session by: $_SESSION['currentUser'] = new User($_POST['username']); F...