Jump to content

Insert new table into mysql, phpmyadmin, using PHP


sridhar golyandla

Recommended Posts

look at this example i made yesterday.

 

<?php

$connect_database=mysql_connect("localhost","username","password")
or die("Databse connection problam".mysql_error());

$sql="CREATE DATABASE website_links";
$res=mysql_query($sql)or die(mysql_error());

$sql2="USE website_links";
$res2=mysql_query($sql2)or die(mysql_error());

$sql3="CREATE TABLE link_stats(
stat_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
car_stats INT DEFAULT '0' NOT NULL,
van_stats INT DEFAULT '0' NOT NULL,
truck_stats INT DEFAULT '0' NOT NULL
)";

$res3=mysql_query($sql3)or die(mysql_error());


$sql4="INSERT INTO link_stats(car_stats,van_stats,truck_stats) VALUES('1','1','1')";

$res5=mysql_query($sql4)or die(mysql_error());


if($res5){
   
   echo" DATABASE CREATED THANK YOU!";
}

?>

 

 

  Quote

Maq,

 

      i want to store a new table from local system into phpmyadmin through php code?

 

Sure just do a mysqldump (you can specify a single table).

 

Then, if you have ssh access, you can run this in the command prompt:

 

mysql 

 

If you don't have ssh access let me know, there's another solution.

will help.

 

If you know how to do it with a commandline what's wrong with

exec("mysql < test.sql"); ?

 

http://www.ozerov.de/bigdump.php

 

http://drupal.org/node/43024

 

<?php
// Database configuration

$db_server        = "localhost";
$db_name         = "your_DB_name";
$db_username  = "your_DB_user_name";
$db_password   = "your_DB_password";


// Other Settings

// Specify the dump filename to suppress the file selection dialog
$filename             = "the_file_you_wish_to_execute";    

// Lines to be executed per one import session
$linespersession  = 3000;

// You can specify a sleep time in milliseconds after each session
// Works only if JavaScript is activated. Use to reduce server overrun
$delaypersession = 0;     
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.