I've been experimenting with a library script, and this particular script is to be used when you have to sign books in. The form that calls it is basically check boxes of all books that are currently checked out. Then you select which ones to sign in. It creates a parameter in the URL with the books name. Say you had a book called test that you wanted to sign in. The URL would looks like this.
http://domain.com/script.php?Test=on
This script is supposed to check if the parameter is set to on, and if so, set it to be checked in. However, if you had a book called Test 2, the URL would look like this:
http://domain.com/script.php?Test+2=on
If I try to check this book in, it won't, because it tries to check in Test+2 instead of Test 2.
My guess would be to convert all + to a space. I could do this in Perl, but I'm new at PHP, and couldn't find any info at php.net.
So, this is the script I am currently using. Any changes would be great.
<?php
mysql_connect("localhost","username","password");
mysql_select_db("library");
$q=mysql_query("SELECT * FROM bemc_books WHERE checked_out='y'");
while ($row=mysql_fetch_row($q)) {
$var = $_GET[$row[0]];
if ($var == 'on') {
mysql_query("UPDATE bemc_books SET checked_out='n' WHERE name='$row[0]'")
|| die("Error: ".mysql_error());
print "Book Checked In Successfully";
}
else { print "Couldn't Check Book In."; }
}
?>