Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:32:11+00:00 2026-06-12T02:32:11+00:00

So I wrote a PHP script in order to upgrade my previous MySQL db

  • 0

So I wrote a PHP script in order to upgrade my previous MySQL db to a new one with new relations and stuff. Everything seemed to be working fine until I noticed I had some entries missing in my new db. My old db shows 322 records for that table and my new one shoes only 95. So since some entries made it, I have no idea on where the problem is can anyone help me?

Here is my code, and i am having this problem only in table POIS that has bigint,varchar,double and float:

<?
include("mysql.class.php");


$db_old = new mysqli("localhost", "root", "admin", "smarturbia_old");
$db = new mysqli("localhost", "root", "admin", "smarturbia");

$categories = array();;


$db->query("INSERT INTO categories(name) VALUES('taxi')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('golf')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('usa')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('car')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('moon')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('scooter')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('motocross')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('supercar')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('europe')") or die($db->error.__LINE__);
$db->query("INSERT INTO categories(name) VALUES('snow')") or die($db->error.__LINE__);


$result = $db->query("SELECT * FROM categories") or die("Não foi possível selecionar a base de dados");


        if($result->num_rows > 0) {
            while($row = $result->fetch_assoc()) 
                $categories[$row['name']] = $row['id'];         
    }
    else 
            echo 'NO RESULTS';  

$result = $db_old->query("SELECT * FROM cities") or die($db_old->error.__LINE__);


        if($result->num_rows > 0) {
        while($row_old = $result->fetch_assoc()) {
                        $sql="INSERT INTO `cities` VALUES (".$row_old['id'].",'".$row_old['published']."', '".$row_old['open']."', '".$row_old['path']."', '".$row_old['key']."', '".$row_old['world']."', '".$row_old['name']."', '".$row_old['description']."', '".$row_old['logo']."' , '".$row_old['footer']."', '".$row_old['footer_large']."' , '".$row_old['leftpub']."', '".$row_old['rightpub']."' ,'".$row_old['model']."', ".$row_old['modelxscale'].", ".$row_old['modelyscale'].", ".$row_old['modelzscale'].", ".$row_old['wheelmodelxscale'].", ".$row_old['wheelmodelyscale'].", ".$row_old['wheelmodelzscale'].", '".$row_old['allwheels']."', '".$row_old['frontleftwheel']."', '".$row_old['frontrightwheel']."', '".$row_old['rearleftwheel']."', '".$row_old['rearrightwheel']."', ".$row_old['axisdistance']." , ".$row_old['wheelsdistance']." , ".$row_old['wheelsheight'].", ".$row_old['kms'].", ".$row_old['maxspeed'].", ".$row_old['accel'].", ".$row_old['accelstep'].", ".$row_old['minaccelstep']." , ".$row_old['maxrevspeed'].", ".$row_old['decel']." , ".$row_old['gravity'].", ".$row_old['camheight'].", ".$row_old['camtilt'].", ".$row_old['traildistance'].", ".$row_old['mass'].", ".$row_old['vehicleagility'].", ".$row_old['suspensionstiffness'].", ".$row_old['suspensionrestlength'].", ".$row_old['suspensiondamping'].", ".$row_old['suspensiondeltatime'].", ".$row_old['turnspeedmin'].", ".$row_old['turnspeedmax'].", ".$row_old['speedmaxturn'].", ".$row_old['speedminturn'].", ".$row_old['steerroll'].", ".$row_old['rollspring'].", ".$row_old['rollclamp'].", '".$row_old['mapiconurl']."', '".$row_old['vehicleshadow']."', '".$row_old['vehiclesound']."', ".$row_old['vehiclesoundtime'].", '".$row_old['vehiclefastsound']."', ".$row_old['vehiclefastsoundtime'].", '".$row_old['backgroundsound']."', ".$row_old['backgroundsoundtime'].", '".$row_old['crashsound']."', ".$row_old['crashsoundtime'].", '".$row_old['vehicletype']."', '".$row_old['date']."' , ".$categories[$row_old["path"]]. ")";
                        try {
                            $db->query($sql);
                        }
                        catch (Exception $e){
                            echo 'Caught exception: ',  $e->getMessage(), "\n";
                        }                    
                }
    }
    else {
        echo 'NO RESULTS';  
    }


$result = $db_old->query("SELECT * FROM kmz") or die($db_old->error.__LINE__);

            if($result->num_rows > 0) {
        while($row_old = $result->fetch_assoc()) {
                        $sql="INSERT INTO `kmz` VALUES (".$row_old['id'].",".$row_old['city'].", '".$row_old['file']."','".$row_old['date']."')";
                        try {
                            $db->query($sql);
                        }
                        catch (Exception $e){
                            echo 'Caught exception: ',  $e->getMessage(), "\n";
                        }                    
                }
    }
    else {
        echo 'NO RESULTS';  
    }


$result = $db_old->query("SELECT * FROM pois") or die($db_old->error.__LINE__);

            if($result->num_rows > 0) {
        while($row_old = $result->fetch_assoc()) {
                        $sql="INSERT INTO `pois` VALUES (".$row_old['id'].",".$row_old['city'].", '".$row_old['name']."','".$row_old['description']."',".$row_old['lat'].", ".$row_old['lon'].",".$row_old['heading'].")";
                        try {
                            $db->query($sql);
                        }
                        catch (Exception $e){
                            echo 'Caught exception: ',  $e->getMessage(), "\n";
                        }                    
                }
    }
    else {
        echo 'NO RESULTS';  
    }


        //Just for consistency

        try {
            $db->query("INSERT INTO `smarturbia`.`limits` (`id`, `city`, `area`, `lat`, `lon`, `date`) VALUES (NULL, '76', NULL, '23.34343434', '-3.343343434', CURRENT_TIMESTAMP);");
            $db->query("INSERT INTO `smarturbia`.`area` (`id`, `city`, `name`, `date`) VALUES (NULL, '76', 'areateste', CURRENT_TIMESTAMP);");
            $db->query("UPDATE  `smarturbia`.`limits` SET  `area` =  '1' WHERE  `limits`.`id` =1;");

            //for sound
            $db->query("UPDATE  `smarturbia`.`cities` SET  `vehiclesound` =  '/assets/sounds/vehicle.ogg';");
            $db->query("UPDATE  `smarturbia`.`cities` SET  `backgroundsound` =  '/assets/sounds/background.ogg';");
            $db->query("UPDATE  `smarturbia`.`cities` SET  `crashsound` =  '/assets/sounds/crash.ogg';");


        }
        catch (Exception $e){
            echo 'Caught exception: ',  $e->getMessage(), "\n";
        }    

        echo 'Done';
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:32:12+00:00Added an answer on June 12, 2026 at 2:32 am

    So i figured it out, the problem was my special characters, so i mysqli real_escape_string() to fix my problem. Thanks anyways guys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a PHP script that retrieves values from a MySQL Query. I used
I wrote a PHP script to list all the tables present in the database
I wrote a php script that must be run on the php interpreter (Without
I'm using Dynatree for the first time and wrote a PHP script that returns
I wrote a PHP-CLI script that mixes two audio (.WAV PCM) files (with some
I just wrote a PHP login script, and what I'm trying to accomplish is
I write curl php script which work is download csv file from one website
I wrote a bash script which can modify php.ini according to my needs. Now
I wrote this php script to delete old files older than 24 hrs, but
I am working with multiple databases in a PHP/MySQL application. I have development, testing,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.