PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 25th, 2012, 02:46 AM
chinkoo chinkoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 13 chinkoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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'

Reply With Quote
  #2  
Old November 25th, 2012, 03:20 AM
ttremain ttremain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Location: Vancouver, WA, USA
Posts: 364 ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level)ttremain User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Days 7 h 49 m 59 sec
Reputation Power: 188
Here you try to alter the table to add three columns. The second time you run your code, you will error out, because they were already created before.

Code:
$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));
__________________
Thomas Tremain

Reply With Quote
  #3  
Old November 25th, 2012, 07:42 AM
chinkoo chinkoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 13 chinkoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 3 m 13 sec
Reputation Power: 0
thanx

thanx thomas ur reply was reallly helpful!! thanx a lot thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - New to php

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap