I can't solve the error in the code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux