-3

I'm working on a larger Project that installs a php interpreter via xampp and mariaDB together with a larger project, containing a database and some php files on a blank windows 10 system.

i got everything running so far, the php server is running on command and the mariadb server seems to be reachable too.

The problem I'm facing lies in the fact that our project (which works perfectly under phpstorm and via command line on ANOTHER SYSTEM) doesn't seem retrieve the table data of our database in this VM.

The connection from inside the php is working and the database itself gets recognized too. I checked that by printing it like this:

$dbhost = "localhost"; 
 $dbuser = "root"; 
 $dbpass = "toor"; 
 $dbname = "emensawerbeseite";
 $dbport = "42069";
 $link= mysqli_connect ($dbhost, $dbuser, $dbpass,$dbname,$dbport);
      
         if(! $link ) {
            die('Could not connect: ' . mysqli_error());
         }
         
         echo 'Connected successfully</br>';
$link->set_charset("utf8"); //enables the good old äüö's

$db_list = mysqli_query($link, "SHOW DATABASES"); //mysqli

while ($row = mysqli_fetch_object($db_list)) {
 echo $row->Database . "</br>";
}  

this prints me this output:

first output

I can also list the all table column names.

The database itself I just Copied in the data folder of mariadb. It persists of the same .frm and .ibd and .opt file(s), that my working version has.

Problem lies when i try to insert or retrieve any sort of actual data from the database e.g. like this.

$sql2 = "insert into gericht (id, name, beschreibung, erfasst_am, vegetarisch, vegan, preis_intern, preis_extern) values (22, 'CCurrywurst mit Pommes', '', '2022-11-14', false, false, 4.20, 6.90)";

if ($link->query($sql2) === TRUE) {
  echo "New record created successfully";
} else {
  echo "Error: " . $sql2 . "<br>" . $link->error;
}

Which is when the the following Error appears:

"Fatal error: Uncaught mysqli_sql_exception: Table 'emensawerbeseite.gericht' doesn't exist in engine in C:\xampp\php\index.php:43 Stack trace: #0 C:\xampp\php\index.php(43): mysqli->query('insert into ger...') #1 {main} thrown in C:\xampp\php\index.php on line 43"

What does this actually mean?

And what could i do about it? Some Posts suggested to just restart or other things that didn't work.

Gisbert12843
  • 76
  • 1
  • 10
  • "Table 'emensawerbeseite.gericht' doesn't exist" - anything unclear about that? – Nico Haase Nov 25 '22 at 14:08
  • yes many things.. because i can literally print out "emensawerbeseite.gericht"'s column names in the same php code.. and also see its files in the explorer.. it should exist – Gisbert12843 Nov 25 '22 at 14:10
  • 2
    `The database itself I just Copied in the data folder of mariadb.`...this really isn't a recommended or supported way to restore a database. This alone could cause some form of corruption, potentially. Just because the table is listed in the information schema doesn't necessarily means it actually exists in reality. If you copy the database using an unsupported method, then you've no guarantee it's going to work properly. Read https://mariadb.com/kb/en/backup-and-restore-overview/ and migrate your database in the correct manner. Then see if you still have a problem. – ADyson Nov 25 '22 at 14:21
  • oh ok that could actually be a problem yeah.. i will try that! the $link is the right one ^^ thx for the hint! @ADyson – Gisbert12843 Nov 25 '22 at 14:24
  • You have an error. [`mysqli_error()`](https://www.php.net/manual/en/mysqli.error.php) needs one argument. Please consider switching error mode on instead. [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Nov 25 '22 at 15:14
  • [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – Georg Richter Nov 25 '22 at 15:48
  • @GeorgRichter doesnt make sense ^^ – Gisbert12843 Nov 25 '22 at 15:55
  • @GeorgRichter where do you see images of code or errors in the question? Which relevant parts are not present in text form? – Nico Haase Nov 25 '22 at 15:55
  • @NicoHaase he means the output i included ^^ I could put it in textform but this way its way more clear i feel.. – Gisbert12843 Nov 25 '22 at 15:57

1 Answers1

2

"Table 'emensawerbeseite.gericht' doesn't exist in engine"

This means that your database is corrupted. In case of InnoDB the dictionary (ibdata1) doesn't contain information about table gericht or is missing at all.

Georg Richter
  • 5,970
  • 2
  • 9
  • 15