Jump to content

Connecting mysql to PHP


Misomurai

Recommended Posts

Hey, can someone tell me what's wrong with this code?

My browser says that line 3 is wrong, but I'm not sure what's wrong about it.

Thanks 

 

--------------------------------------------------------------------------------------------

 

<?php
    if ($_POST['submit1'] != ''){
      $link = mysql_connect("$dbname", "$_library_lab", "$password");
      if (!$link == FALSE) {
        $database = mysql_select_db('bookmark');
        if ($database==TRUE){
          $name = $_POST['name'];
          $book = $_POST['book'];
          $bookmark = $_POST['bookmark'];
          $shiori = $_POST['shiori'];
 
          $sql="insert into bookmark (name, book, bookmark, shiori) values('{$name}','{$book}','{$bookmark}','{$shiori}')";
          $result = mysql_query($sql);
          if ($result == TRUE){
          }else{
            echo('DB insert Failure!');
          }
        }
        mysql_close($link);
      }
    }
    ?>
Link to comment
Share on other sites

The variables you are passing to mysql_connect(), wehere are they defined? And why the hell are they in quotes?

 

ps: The mysql extension has been deprecated. All new code should be using mysqli or PDO.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.