php

How dangerous is this PHP code?

How dangerous is this php code? What can be done about it? $name = $_POST["user"]; $pwd = $_POST["pwd"]; $query = "SELECT name,pwd FROM users WHERE name = '$name' AND pwd = '$pwd'"; ...

Checking browser's language by PHP?

How can I check the language of user's browser by PHP? I need to show a different page for people in US and in UK. I tried the following code unsuccessfully <?php if(ereg("us", $_SERVER["HTTP_ACCEPT_LANGUAGE"])) include('http://page.com/us.txt'); else include('http://page.com/uk.txt'); ?> I run a specific code for people in US...

Counting multiple entries in a MySQL database?

Hi all, I'm trying to count multiple entries in a MySQL database, I know how to use COUNT(), but the exact syntax I want to get the results I need eludes me. The problem: Table structure: ID, CODE, AUTHOR, COUNTRY, TIMESTAMP. Code, Author and Country overlap many times in the table. I am trying to discover if there is one simple query...

How do you make __call() method for function calls?

Hi, I am trying to develop an application that intercepts functions. I know in class methods, you can have a __call() method for functions. I am wondering if such a thing exists for regular functions? I know there is a "function_exists" call, but then I'd have to do that everytime I call a function. I'd like an automated approach. Any h...

Where do you get news about PHP? What websites you learn from?

What websites you visit to learn and know something new and interesting about PHP? I can't seem to find any. I'm interested in sites where one can get advanced content. Thanks! ...

how to display all the possible data greater than the current date

$Date = date("m/d/Y"); $result = mysql_query("SELECT * FROM service WHERE SType = 'Retreat' and Start_date > '$Date' "); Start_date format is m/d/y also. whats wrong with my code? all i want to do is to display all the possible data greater than the current date. but it always show all the data from the database. ...

PHP memory limit

In PHP 5.0.4, if you don't configure -enable-memory-limit, the memory_limit directive is ignored. (It's set to 8M in the recommended php.ini file, but the documentation says it's ignored.) So in that case, is there a per-script memory limit at all, or is it only limited by the system? I ask because I'm upgrading to PHP 5.2.8, and it doe...

Best method for storing a list of user IDs

I'm working on a PHP/MySQL rating system right now. For the user to be able to rate the user has to log in. Each user has a unique "UID". There will be multiple rating instances on the website (one for every game, in my case) and I need an efficient way of storing a list of UIDs in a MySQL row (one MySQL row in the ratings table for each...

What is an easy way to put an element in the middle of a PHP array?

Say you have a 10 element indexed array and you want to place an element somewhere in the middle (say index 3). Then I want to have the rest of the array shift and thus be 11 elements long. Is there an easy way to do this? I am surprised there is no put() function or something. I know it would be easy enough to do this with a combinati...

Load PNG and read pixels in PHP without GD?

I have a need to read in the exact unaltered pixel data (ARGB) from a truecolour PNG file, preferably from PHP. Unfortunately the GD library in PHP messes with the alpha channel (reducing it from 8-bit to 7-bit), making it unusable. I'm currently assuming that my options are either: Implement my own raw PNG reader to extract the nece...

How do you encode an apostrophe so that it's searchable in mysql?

I don't think that was the most clear question, but an example should make it a little clearer. I have a table filled with movie names, some of which contain apostrophes. I have a search box which is used to find movies. If I perform searches via mov_title = '$search_keywords' it all works, but this method will not yield any resul...

How to insert data from html form into database without using HTML POST method?

Hi I would like to know if there is any other way using javascript or something to enter the user input directly to database without using POST method. ...

Add a Blog to an Existing Webpage.

How can I insert a blog (not created yet) into and already existing 'static' webpage? The webpage is written mostly in php. I'm considering using something like wordpress.org (host install version) and using it to update the website's news page. From what I've read, its sounds like I would need to do a lot of theme tweaking to get word...

Efficient MySQL table structure for rating system

This post is a follow-up of this answered question: Best method for storing a list of user IDs. I took cletus and Mehrdad Afshari's epic advice of using a normalized database approach. Are the following tables properly set up for proper optimization? I'm kind of new to MySQL efficiency, so I want to make sure this is effective. Also,...

How do you make websites with Java?

This might be a really trivial question, but I've been writing Java programs at my school. But I just found out that I can create websites with Java as well. How can I do that? Any good books/tutorials for that? Also, I know about PHP, which is better for Web development? Also, when using PHP, MySQL comes into picture and while writing J...

SQL - INSERT and catch the id auto-increment value

What is the best way to get the auto-id value in the same SQL with a SELECT? A forum said adding this "; has Return Scope_Identity()" in the end of the SQL works in ASP. Is there a corresponding way in PHP? ...

PHP Compilers, do you know of any?

I'm looking at various PHP compilers that turn PHP into native ELF executables. So far, I know of PHC and Roadsend. Do you know of any others? Do you have any experiences to share? Note, I'm interested in any PHP compiler, not just those that are Zend specific. If you are using one of the compilers linked above, I'd greatly appreciate ...

SWF object not playing my XML Playlist.

Hello, I've tried to include youtubetune player to social network, but for somereason it wont play the xml files it should play. I got around issue that the tracks dint even appear by uploading the neccessary swf files and swfobject.js file to my server. Now the tracks appears to the player, but the player wont play them. You can see my...

Insert variables and arrays in different database tables using PHP and MySQLi

Hi, I'm learning PHP and MySQL and I'm creating a movies website for learning purposes. I want to insert variables and arrays containing movie info into a database but in different tables. This is what I have right now: include('inc/connection.php'); $conn = dbConnect(); // create SQL $sql = 'INSERT INTO movies (movieid, title, year,...

Why are my file permissions on Apache being reset?

We recently switched from using PCs at work to Macs, so I'm new to the *nix way of doing things. I have the default Apache running that shipped with 10.5, but I've noticed that when I drag files from a Windows server to my machine, the permissions are changed. Specifically, I'm writing data to an XML file, and occasionally after swapping...