I am just getting started with PHP and mySQL. I worte this page to add data to the mySQL server and when I run the page the only error I get is "Call to undefined function mysql_qwery()". I have looked over the code about 300 times and I can't see the error. Maybe some fresh eyes will do some good.
<?php
if ($_POST['shortbtn']) {
$url = $_POST['url'];
if ($url) {
require("./connect.php");
$charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
$len = 5;
$numrows = 1;
while ($numrows != 0){
for ($i = 0; $i <= $len; $i++){
$rand = rand() % strlen($charset);
$tmp = substr($charset, $rand, 1);
$code = $tmp;
}
$qwery = mysql_qwery("SELECT * FROM items WHERE code='$code'");
$numrows = mysql_num_rows($qwery);
}
$date = date("F d, Y"); //Feburary 29, 2012
mysql_qwery("INSERT INTO items VALUES ('', '$url', '$code', '$date')");
$qwery = mysql_qwery("SELECT * FROM items WHERE code='$code'");
$numrows = mysql_num_rows($qwery);
if ($numrows == 1){
$site = "http://localhost";
echo "Here is your shortened URL: <input type='text' size='40' value='$site/$code'";
}
else
echo "Your info was not added.";
mysql_close();
}
else
echo "<script type='text/javascript'>window.location = './index.php'</script>";
}
else
echo "<script type='text/javascript'>window.location = './index.php'</script>";
?>