Alright so me and my friend are hosting our own website. We have everything we need installed on it.

Just last week we got a video uploading script to work, thanks to some people on here. What the script does is uploads the video to the database and writes info for the video (video title, description, etc.) to a database. Because of all the tests we did on the MySQL database, we decided to delete and recreate the database itself, so that I didn't have to manually delete every row in the table.

Fast forward to today, the first time I'm using the script since the database was deleted. I'm uploading a video, and I get this error:

Can't create table '.\porn\videos.frm' (errno: 121)

This is really weird because since the database was deleted and recreated, neither me or my friend had touched the PHP script. It was working perfectly before the database was recreated, so I'm really confused.

Here's the code I'm using (and yes, the password is blank on purpose):

<?php 
$con = mysql_connect("localhost","root",""); 
if (!$con) 
  { 
  die('Could not connect: ' . mysql_error()); 
  } 

$fTitle = mysql_escape_string($_POST['fTitle']); 
$fDesc = mysql_escape_string($_POST['fDesc']); 
$fName = mysql_escape_string($_POST['fName']); 
$gName = mysql_escape_string($_POST['gName']); 

// Create table in database 
mysql_select_db("stuff", $con); 
$sql = 'CREATE TABLE IF NOT EXISTS videos ( 
        fTitle varchar(30), 
        fDesc text, 
        fName text, 
        gName text 
    )'; 
$result = mysql_query($sql); 

if(!$result) 
  die( mysql_error() ); // No reason to move on if we've got no table 

echo "Database Table Created...<br>"; 

//Inserting Data 
mysql_query("INSERT INTO videos (fTitle, fDesc, fName, gName) 
VALUES ('$fTitle', '$fDesc', '$fName', '$gName')"); 
echo "Data Inserted...<br><br>"; 

//Displaying Data 
$result = mysql_query("SELECT * FROM videos"); 
if(!$result) 
  echo mysql_error(); 

echo "<table border='1'> 
<tr> 
<th>Video Title</th> 
<th>Video Description</th> 
<th>File Name</th> 
<th>Star's Name</th> 
</tr>"; 
while($row = mysql_fetch_array($result)) 
  { 
  echo "<tr>"; 
  echo "<td>" . $row['fTitle'] . "</td>"; 
  echo "<td>" . $row['fDesc'] . "</td>"; 
  echo "<td>" . $row['fName'] . "</td>"; 
  echo "<td>" . $row['gName'] . "</td>"; 
  echo "</tr>"; 
  } 
echo "</table>"; 
echo "<br><br><br>"; 

$file_name = $_FILES['ufile']['name']; 

$path= "uploads/" . $fName; 
if(is_uploaded_file($_FILES['ufile']['tmp_name'])) 
  { 
  if(move_uploaded_file($_FILES['ufile']['tmp_name'], $path)) 
    { 
    echo "Successful!<BR/>"; 

echo "File Name:" . $fName . "<BR/>"; 
echo "File Size: ".$_FILES['ufile']['size']." bytes <BR/>"; 
echo "File Type:".$_FILES['ufile']['type']."<BR/>"; 
} 
  else 
    { 
    echo "Error"; 
    } 
  } 
mysql_close();

Anyone have any idea what's going on here. I'm completely lost.

    Risingstar wrote:

    Alright so me and my friend are hosting our own website. We have everything we need installed on it.

    Just last week we got a video uploading script to work, thanks to some people on here. What the script does is uploads the video to the database and writes info for the video (video title, description, etc.) to a database. Because of all the tests we did on the MySQL database, we decided to delete and recreate the database itself, so that I didn't have to manually delete every row in the table.

    Fast forward to today, the first time I'm using the script since the database was deleted. I'm uploading a video, and I get this error:

    Can't create table '.\porn\videos.frm' (errno: 121)

    This is really weird because since the database was deleted and recreated, neither me or my friend had touched the PHP script. It was working perfectly before the database was recreated, so I'm really confused.

    Here's the code I'm using (and yes, the password is blank on purpose):

    <?php 
    $con = mysql_connect("localhost","root",""); 
    if (!$con) 
      { 
      die('Could not connect: ' . mysql_error()); 
      } 
    
    $fTitle = mysql_escape_string($_POST['fTitle']); 
    $fDesc = mysql_escape_string($_POST['fDesc']); 
    $fName = mysql_escape_string($_POST['fName']); 
    $gName = mysql_escape_string($_POST['gName']); 
    
    // Create table in database 
    mysql_select_db("stuff", $con); 
    $sql = 'CREATE TABLE IF NOT EXISTS videos ( 
            fTitle varchar(30), 
            fDesc text, 
            fName text, 
            gName text 
        )'; 
    $result = mysql_query($sql); 
    
    if(!$result) 
      die( mysql_error() ); // No reason to move on if we've got no table 
    
    echo "Database Table Created...<br>"; 
    
    //Inserting Data 
    mysql_query("INSERT INTO videos (fTitle, fDesc, fName, gName) 
    VALUES ('$fTitle', '$fDesc', '$fName', '$gName')"); 
    echo "Data Inserted...<br><br>"; 
    
    //Displaying Data 
    $result = mysql_query("SELECT * FROM videos"); 
    if(!$result) 
      echo mysql_error(); 
    
    echo "<table border='1'> 
    <tr> 
    <th>Video Title</th> 
    <th>Video Description</th> 
    <th>File Name</th> 
    <th>Star's Name</th> 
    </tr>"; 
    while($row = mysql_fetch_array($result)) 
      { 
      echo "<tr>"; 
      echo "<td>" . $row['fTitle'] . "</td>"; 
      echo "<td>" . $row['fDesc'] . "</td>"; 
      echo "<td>" . $row['fName'] . "</td>"; 
      echo "<td>" . $row['gName'] . "</td>"; 
      echo "</tr>"; 
      } 
    echo "</table>"; 
    echo "<br><br><br>"; 
    
    $file_name = $_FILES['ufile']['name']; 
    
    $path= "uploads/" . $fName; 
    if(is_uploaded_file($_FILES['ufile']['tmp_name'])) 
      { 
      if(move_uploaded_file($_FILES['ufile']['tmp_name'], $path)) 
        { 
        echo "Successful!<BR/>"; 
    
    echo "File Name:" . $fName . "<BR/>"; 
    echo "File Size: ".$_FILES['ufile']['size']." bytes <BR/>"; 
    echo "File Type:".$_FILES['ufile']['type']."<BR/>"; 
    } 
      else 
        { 
        echo "Error"; 
        } 
      } 
    mysql_close();
    

    Anyone have any idea what's going on here. I'm completely lost.

    It seems to be a known issue with mySQL when manually deleting tables and then recreating them while using the InnoDB type. Google results.

      Pikachu2000 wrote:

      It seems to be a known issue with mySQL when manually deleting tables and then recreating them while using the InnoDB type. Google results.

      I know... I googled to see if I could find something before I posted (like a good little boy) 🙂. Unfortunately, none of the answers given in the google results helped me, or related to my situation.

        OK, you've broken the rules of how to drive MySQL and now it doesn't wanna run properly.

        It's time to stop the db, delete the data directory and reinitialize the whole DB.

        Not sure how to do that in mysql, but the admin docs probably do. Possibly deleting the database that held the tables will work.

        Then, stop deleting database files by hand.

          Risingstar wrote:

          I know... I googled to see if I could find something before I posted (like a good little boy) 🙂. Unfortunately, none of the answers given in the google results helped me, or related to my situation.

          One of the articles mentioned recreating the tables as MyISAM instead of InnoDB. I didn't look too deeply into it, however.

            I wonder if recreating in myisam then allows you to recreate the same table in innodb format?

            I wouldn't trust the db now myself. Not until it's been recreated from scratch.

              I fixed this.

              Just made a new database called stuff2.

                Write a Reply...