I can't solve the error in the code
| From: | Alexander | Date: | Sun, 28 Jan 2007 00:09:41 +0000 |
| Subject: | I can't solve the error in the code | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-42989@lists.php.net to get a copy of this message | ||
I'm writing a script for uploading into a database urls for a picture and its thumbnail, but
for some reason when I test it out the page doesn't load, and not even the errors appear.
Please help, here's the code:
<html>
<body>
<?php
$user = "userone";
$pass = "password";
$database = "mydatabase";
$link = mysql_connect("localhost", $user, $pass);
if(!$link) {
echo 'Error in linking';
}
$db = mysql_select_db($database, $link);
if(!$db) {
echo 'Error in DB';
}
else {
if ( !empty( $_REQUEST['picture'] ) && !empty(
$_REQUEST['thumbnail'] ) ) {
$input = add_to_table( $_REQUEST['picture'], $_REQUEST['thumbnail']
);
if(!input) {
echo 'Error\!';
}
else {
echo 'Data enter successfully\!';
}
}
else {
write_form();
}
function add_to_table( $picture, $thumbnail ) {
$picture = mysql_real_escape_string($picture);
$thumbnail = mysql_real_escape_string($thumbnail);
$insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture, $thumbnail
)';
$indata = mysql_query( $insert, $link );
}
function write_form() {
print <<<EOF
form method='post' action='{$_SERVER['PHP_SELF']}'>
<p>Enter url of large picture: <input type='text'
name='picture' />
<p>Enter url of thumbnail: <input type='text'
name='thumbnail' />
echo '<p><input type='submit' value='Add to Database'
/>'
</form>;
FORM;
}
?>
</body>
</html>