I needed to recommend to the visitor similar items to the one they where looking at. So I asked in another question for a SQL query to get items with the same categories (from a 'categories' table). The next is the correct code I'm actually using:
SELECT c2.itemID
FROM categories c1
JOIN categories c2 ON c1.catID = c2.catID
WHERE c1.ite...
I found this function that tests whether a string is Windows filename and folder friendly:
function is_valid_filename($name) {
$parts=preg_split("/(\/|".preg_quote("\\").")/",$name);
if (preg_match("/[a-z]:/i",$parts[0])) {
unset($parts[0]);
}
foreach ($parts as $part) {
print "part = '$part'<br>";
...
When checking that variables passed via GET and POST are correct, I might have something like this:
<?php
//Controller
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(!isset($_POST['new_email']))
header('Location: somepage.php');
else if(empty($_POST['new_email']))
//Report error to user and prompt to try again
else
$new...
hey there
i have a directory inside my wordpress directory for some template application
apacheWWW/wordpress/jtpc
in my application i want the wordpress current user id
i am able to do this in one page but in the other i get an error
this is what i am doing to get the user id
require_once( '/../../wp-load.php' );
global $curre...
Hello,
I am very new to php and trying to work stuff around as they come across.
I am trying to display the output of a query on the web page. Following is the code.
<?php
$username="xxxxxxxxx";
$password="xxxxxxxxx";
$database="xxxxxxxxx";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable...
I need to convert animated GIF to static in PHP. I mean e.g. use its first frame. Any idea how to do that ?
...
So I've recently been converted to Eclipse from Textpad [wow I didn't know what I was missing] and the only main complaint is I can't figure out how to how to get my brackets to be a different color. I changed all the other colors to my old look so I guess my real problem is I can't add new rules to the list of different template items ...
Would like http://websites.com/users/username1 URL structure
...
Can anyone think of a better way of writing this out in a loop and getting the same result?
$today = date('l');
if($today == 'Wednesday'){
$min = date('l-m-d-y');
$max = date('l-m-d-y', strtotime('+4 days'));
}else if($today == 'Thursday'){
$min = date('l-m-d-y', strtotime('-1 days'));
$max = dat...
I have a node which references other nodes.
If I give a user custom access to this node, how do I set it up so that he automatically gets access to those other nodes as well?
...
I want to post something to my database which consists of two tables which are linked with a foreign key. I want to be able to post something to the first table which has only two cells (city and city_id) via php and then get redirected to the second table where someone can post detail about places of the city (houses squares ect (city_i...
I'm modifying PHP Markdown (a PHP parser of the markup language which is used here on Stack Overflow) trying to implement points 1, 2 and 3 described by Jeff in this blog post. I've easily done the last two, but this one is proving very difficult:
Removed support for intra-word
emphasis like_this_example
In fact, in the "normal" mark...
hey all,
is it possible to have some sort of very simple reversible encryption in php that can be reversed using C# Winforms?
thank you
...
Hello,
I'm a pretty seasoned PHP developer, and have integrated APIs before with platforms like PayPal and Authorize.Net after finding classes to work with... It's just that now I have to implement with limelight network's API and I have to start from scratch... Here's what I want to do after receiving a callback, posted to a PHP page I...
I'm trying to split an HTML string by a token in order to create a blog preview without displaying the full post. It's a little harder than I first thought. Here are the problems:
A user will be creating the HTML
through a WYSIWYG editor (CKEditor).
The markup isn't guaranteed to be
pretty or consistent.
The token, read_more(), can
be ...
I use mysqli extension and bind the result to an object:
class Item {
public $id, $name;
}
$Item = new Item;
$stmt->bind_result($Item->id, $Item->name);
Every call to $stmt->fetch() will overwrite $Item's properties which became references. If I simply clone the object — these references remain and both instances change simult...
I'm working on a project in PHP that needs to render dynamically-created SVG images to PNG (or GIF if not PNG) format. I know I can do this by invoking a SVG renderer like rsvg, or with an extension like ImageMagick, which isn't that common*.
Is there a "drop-in" style library that can render SVG using things like GD and DomDocument?
...
I'm an intermediate PHP developer with no experience building a large scale web application in this language (though I have in others, mainly Rails)...say I wanted to build a social networking site using PHP and MYSQL (preferably) with all the web 2.0 trimmings.
Where should I start? What sort of frameworks should I be looking at? Any...
Does PHP have a virtual machine like Java?
...
I have a simple online product that I'm selling. I need a credit card order form.
I'm looking for a sample php based order form. A form that collects name, address, credit card, exp date, and cvv and validates that the fields (for example checks that the credit card number is in the correct format). Forget the payment gateway integrati...