0

I exported a database table into a .sql file. After that I reinstalled WAMP, I made a new database and imported the table.

The imported table doesnt work, which settings in mysql should I check for having a succesful migration?

this the code

if (isset($_POST['send'] )  )
{

$servername = "****";
$username = "****";
$password = "****";
$dbname = "****";

$conn = new mysqli($servername, $username, $password,       $dbname);
if ($conn->connect_error) { die("Connection failed: " . $conn    >connect_error);}



$sql = "INSERT INTO $tabel (fname, lname, strnu, poco, place, pro_reg,    country, email, tele, mobi, citizen, pport_id, birthday, cl_nr, sxmf) VALUES 
                     ('$fname' , '$lname' , '$strnu' , '$poco' , '$place' , '$pro_reg' , '$country' , '$email' , '$tele' , '$mobi' , '$citizen' , '$pport_id' , '$birthday' , '$cl_nr' , '$sxmf')" ; 
                        if ($conn->query($sql) === TRUE)

                            {  echo' Thank you for completing this form'; 
                                var_dump($fname);                               

                            }   else { 

                            echo "Error: " . $sql  ;
                            $conn->error;

                            }

$hi_val = mysqli_insert_id($conn);                      
// data fetch
$sql2 = "SELECT id, fname, lname, strnu, poco, place, pro_reg, country,   email, tele, mobi, citizen, pport_id, birthday, cl_nr, sxmf FROM $tabel WHERE id  = $hi_val";
$result = $conn->query($sql2);


// output data of each row
while($row = $result->fetch_assoc()) {

    //var_dump($hi_val);

  //  echo 'id: ' . $row["id"];


    $fname = $row["fname"];
  // etc
} 
}

and here is the table I made:

-- phpMyAdmin SQL Dump
-- version 4.5.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generated: 19 jul 2016 at 07:42
-- Server version: 5.7.11
-- PHP-version: 5.6.19

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `dbase_name`
--

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

--
-- Tabelstructure for table `user`
--

CREATE TABLE `user` (
`fname` text NOT NULL,
`lname` text NOT NULL,
`strnu` varchar(45) NOT NULL,
`poco` varchar(15) NOT NULL,
`place` text NOT NULL,
`pro_reg` varchar(30) NOT NULL,
`country` text NOT NULL,
`email` varchar(40) NOT NULL,
`tele` varchar(20) NOT NULL,
`mobi` varchar(20) NOT NULL,
`citizen` text NOT NULL,
 `pport_id` varchar(25) NOT NULL,
`birthday` varchar(15) NOT NULL,
`id` tinyint(3) NOT NULL,
`cl_num` varchar(25) NOT NULL,
`sxmf` text NOT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Index exported tables
--

--
-- Index for table `user`
--
ALTER TABLE `user`
 ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT exported table
--

--
-- AUTO_INCREMENT table `user`
--
ALTER TABLE `user`
 MODIFY `id` tinyint(3) NOT NULL AUTO_INCREMENT;
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

2 Answers2

0

The insert and select statements reference

cl_nr

which is named

cl_num

in the table

Jaydee
  • 4,138
  • 1
  • 19
  • 20
0

I would start by check that your username, password, and tablename are exact.

start MySQL in commandline.

SELECT * FROM mysql.user;

Reset password

UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[username]';

Don't forget to start stop mysql and restart it and remember your new username.

This is from this post

Make sure your PHP file has these updated username and passwords, and also make sure your WAMP server icon is green after restart.

Let me know how it goes and otherwise drop table and re upload. Goodluck!

Community
  • 1
  • 1
Devin Norgarb
  • 1,119
  • 13
  • 18