I Want Help in MySQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I Want Help in MySQL

    Please i want to prevent inserting same "title" to the table.. My code are below
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
    <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Download File | JayaSriLanka</title>
    <?php
    include("../head.php");
    ?></head><body><?php include("config.php");
    mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());echo "Connected to MySQL<br />";mysql_select_db("jayasri6_dlc") or die(mysql_error());echo "Connected to Database"; mysql_query("INSERT INTO example(url,title,size,date,artist) VALUES('$url','$title', '$size', '$date','$artist')") or die(mysql_error()); echo "data inserted";
    ?>
    <div style="text-align:center"><br /><a href="new.php">Back</a><input type="text" size="10" value="/dl/?file=<?php echo $_GET['title']; ?>"/><hr />
    <br /><br /><?php
    include("../footer.php");
    ?>
    </div></body></html>

    #2
    Just remove the "title" in the mysql query

    Comment


      #3
      put this at insert page
      PHP Code:
      $jaya=mysql_query("SELECT * FROM jayasri6_dlc WHERE title='$title'");
      if(
      $jaya)
      {
      echo 
      "this title already exist";
      } else {
      // submit script

      Comment


        #4
        SQL:
        PHP Code:
        ALTER TABLE jayasri6_dlc
         ADD UNIQUE 
        (title

        Comment

        Working...
        X