php

% _ in search form displays all results

if the search form is blank, it should display an error that something should be entered by the user. it should only show those results which contain the keywords the user has entered in the search textbox. however, if the user enters % or _ or +, it displays all results. how do i display an error when the user enters these wildcard ch...

PHP display some items from an array

I have a big array which i need to display the latest 10 items in it only. what is the best php code to do that? thanks ...

How to find if a date is a valid date, and not greater than year 2038?

Hello, I have a site where users provide some dates, but if they enter year like 12 april 2099, then the I get date in the past (1969). How do I check it and apply a default max safe date? thank you. ...

PHP Saving information to MySQL but not using hard coded code

Hi guys, Thanks everyone for assisting me but know I'm well and truely stuck...hopefully someone can advise? My current code that saves to a MySQL database: $q1 = $_POST["q1"]; $q2 = $_POST["q2"]; $q3 = $_POST["q3"]; $q4 = $_POST["q4"]; $q5 = $_POST["q5"]; $q6 = $_POST["q6"]; $q7 = $_POST["q7"]; $q8 = $_POST["q8"]; $proc = mysql...

Anyone know any good backend user online file manager?

Hi I'm looking for a backend system where your clients can login and upload files to your server, download files from the server and you can delete the users, create users, etc. I do not know the proper name for this kind of software. Maybe its called online file manager? Any recommendations? My server supports PHP, apache and mysq. Th...

How to detect padding on an integer and treat it as a string?

I have this function to prepare variable to be used in a SQL query: function sqlize($mInput) { if (!isset($mInput)) $mInput = "null"; elseif (strtolower($mInput) == "null") { } elseif (is_numeric($mInput)) { } elseif (is_string($mInput)) { $mInput = trim($mInput); $mInput = addslashes($mInp...

Is It Possible to Make Close Sourced PHP Product?

I'm curious that whether all PHP product must be open sourced if it is to be deployed to other's web site. Since PHP code is executed by interpretation, if I have PHP product to be deployed on other's host, it seems no reason to prevent others view the source code. So, PHP product is destined to be open source, right? To be more precis...

php - correct search expression for bbpress

I have a very purdy styled search box in my wordpress install, and looking for continuity I want the same for my bbpress forum - currently I'm failing. For WP I have: <div id="search"> <form action="<?php bloginfo('home') ?>" method="get"> <div class="hiddenFields"></div> <p><input name="s" id="s" maxlength="10...

OpenID like Stack Overflow

I want to create an OpenID login with PHP just like it can be found on Stack Overflow. I know there are many questions for this, but mine is different. If I understood it correctly, every OpenID is defined by a unique URL. But: If I hit the Google button on the Stack Overflow login page, one generic URL is inserted in the text field. ...

Read tab delimited text file into MySQL table with PHP

I am trying to read in a series of tab delimited text files into existing MySQL tables. The code I have is quite simple: $lines = file("import/file_to_import.txt"); foreach ($lines as $line_num => $line) { if($line_num > 1) { $arr = explode("\t", $line); $sql = sprintf("INSERT INTO my_table VALUES('%s', '%s', '%s', ...

Alphanumeric and more

So I am designing a registration page and checking the username is alphanumeric. else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); I use that to do so. Is there any way I can get that to include underscores (_), dash (-), and spaces? Thanks ...

Create MySQL user and database from PHP

Hi, Is there a way to create a new MySQL database, a new MySQL user and give the new user privileges on the new database all using PHP? EDIT - should be pointed out this is run from 1 server to another, so Server A trying to install a DB/user on Server B i've got this: $con = mysql_connect("REMOTE.IP.ADDRESS","root","pass"); mysql_qu...

Read XML with PHP

I am trying to check a field in some XML that is returned from an outside. The XML is returned in a variable call $out and when you view the source of the page you get a XML output of the following, <?xml version="1.0" encoding="UTF-8"?> <ResponseBlock Live="FALSE" Version="3.51"> <Response Type="AUTH"> <OperationResponse> ...

PHP statements, HTML and RSS

Alrighty, I've got another little bit of code that I'm wrestling through. I'm building a conditional sidebar. The goal is to only show blog related stuff when posts in the "blog" category are being viewed. I've got part of it working, but the part where I'm trying to bring in an RSS feed of the category into the sidebar to show as rec...

Is it possible to validate XML against multiple schemas in PHP?

Hi, I'm wondering if it is possible to validate xml against multiple schemas in PHP or I have to merge my schemas somehow. Thanks for an answer! ...

Connect to Facebook chat using PHP?

I'd like to make a bot that periodically logs into facebook's chat network and stores snapshots of the roster. I'm aiming for a dataset that can tell me which of my friends are online when / how often as a demonstration of the privacy risks of facebook. Is there a library I can use to connect to Facebook's XMPP chat network using PHP? ...

Sharing session information between 2 domains?

I am dealing with a booking engine, and I have an oddball specific request from the client. Firstly though, there are two domains: http://my-client.com/ and http://booking-engines.com/my-client/ There exist 4 overall steps: Check availability through a booking console ( specify criteria such as # of adults/kids/dates ). This live...

PHP file_exists and wildcard

Is there a way to write the PHP file_exists function so that it searches a directory for a file with an arbitrary extension. For instance, suppose I knew that a file were called "hello", but I didn't know the extension, how would I write a function that searched for a file called hello.* and returned the name of this file? As far as I ...

How do I get require_login()-like functionality using the new PHP Client Library for Facebook?

Howdy. I've been tasked with making a Facebook game, but I'm new to Facebook development, so I'm just getting started. Apologies in advance if this is a no-brainer to people. I'm having trouble following all the examples I see on sites, and I keep running into missing pages in the Facebook documentation when I am trying to read up. I...

Most effective way working with multiple natural languages

Hi! I am currently working with a codeigniter PHP based application and have come to the point where it's about to go off with multiple languages. Is codeigniters own language class the most effective way to handle languages? Is there any specific language-tools/libraries that are commonly used in PHP apps? Thanks! ...