thank you. That appears to have solved it.
----- Original Message -----
From: Santiago Zarate
To: Alexander
Sent: Saturday, January 27, 2007 7:26 PM
Subject: Re: [PHP-DB] I can't solve the error in the code
if(!input) { // an error here... should be !$input or even
if(!add_to_table( $_REQUEST['picture'], $_REQUEST['thumbnail'] ))
echo 'Error\!';
}
Also you're calling a function that isn't created yet according with your
code, also i dont see
Also in your function add_to_table, has some errors too... like you're NOT
calling a db conection from it... and i guess it should... since i have to do
it with classes... when it comes to functions... you should too...
for your write_form code... i think youre using your code wrong...
also check here: http://ve.php.net/manual/en/function.print.php
there might be more errors... lñemme do a fast debug here:
[EMAIL PROTECTED]:~$ nano php.php
[EMAIL PROTECTED]:~$ php -f php.php
Parse error: syntax error, unexpected $end in /home/santiago/php.php on line
69
that means there's an missing "}" somewhere... if youre on linux... install
php cli and use it to debug... (Or use bluefish that is way more easy) and
quanta to build your code... if you're on windows... well set your ini to
E_ALL, then choose eitther using console for PHP and load the file... or use
your browser and run the script until it runs fine without errors... if you're
using a shared host... create a error function that logs everything into a
file... might save you lots of time...
2007/1/27, Alexander <[EMAIL PROTECTED]>:
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>