
November 25th, 2012, 02:46 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 13
Time spent in forums: 2 h 3 m 13 sec
Reputation Power: 0
|
|
|
PHP-General - New to php
<?php
$db=mysql_connect("localhost","root","") or die("Unable to connect!Pls check your connection parameters.");
mysql_select_db(moviesite,$db) or die(mysql_error($db));
//alter the movie table to include time,cost and takings
$query='ALTER TABLE movie ADD COLUMN(
movie_running_time TINYINT UNSIGNED NULL,
movie_cost DECIMAL(4,1) NULL,
movie_takings DECIMAL(4,1) NULL)';
mysql_query($query,$db) or die(mysql_error($db));
//insert new data into the movie table for each movie
$query="UPDATE movie SET movie_running_time=111,movie_cost=81,movie_takings=242.6 WHERE movie_id=1";
mysql_query($query,$db) or die(mysql_error($db));
$query="UPDATE movie SET movie_running_time=87,movie_cost=10,movie_takings=10.8 WHERE movie_id=2";
mysql_query($query,$db) or die(mysql_error($db));
$query="UPDATE movie SET movie_running_time=164,movie_cost=NULL,movie_takings=33.2 WHERE movie_id=3";
mysql_query($query,$db) or die(mysql_error($db));
echo "Movie database successfully updated";
?>
error is Duplicate column name 'movie_running_time'
|