Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
I wasn't getting any responses in regards to my database
Old 07-28-2009, 09:36 PM I wasn't getting any responses in regards to my database
Experienced Talker

Posts: 41
Name: Crystal
Location: Beverly Hills
Trades: 0
I wasn't getting any responses regarding my php/mysql database problem help. Here is the post.

Hi I need help regarding basic MySQL

I am doing this all by reading a programming book and following the directions but I think the book has some error and I can't figure it out, can someone help me.

So basically, when I open the file table1.php this is what I get as the output.

Unknown column 'movietype' in 'field list'

I'm still a beginner so if someone could help me figure this out It'd be appreciated.

This is my code for the table1.php:
Code:
<?php
//connect to MySQL
$db = mysql_connect('localhost', 'root', '') or
    die('Unable to connect. Check your connection parameters.');
    
    // make sure you're using the right database
    mysql_select_db('moviesite', $db) or die(mysql_error($db));
    
// retrieve information
$query = 'SELECT 
            movie_name, movie_year, movie_director, movie_leadactor, movietype
        FROM
            movie
        ORDER BY
            movie_name ASC,
            movie_year DESC';
        
$result = mysql_query($query, $db) or die(mysql_error($db));

// determine number of rows in returned result
$num_movies = mysql_num_rows($result);
?>

<div style="text-align: center;">
<h2>Movie Review Database</h2>

<table border="1" cellpadding="2" cellspacing="2" 
style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
    <th>Movie Title</th>
    <th>Year of Release</th>
    <th>Movie Director</th>
    <th>Movie Lead Actor</th>
    <th>Movie Type</th>
</tr>

<?php
// loop through the results
while ($row = mysql_fetch_assoc($result)) {
    extract($row);
    echo '<tr>';
    echo '<td>' . $movie_name . '</td>';
    echo '<td>' . $movie_year . '</td>';
    echo '<td>' . $movie_director . '</td>';
    echo '<td>' . $movie_leadactor . '</td>';
    echo '<td>' . $movie_type . '</td>';
    echo '</tr>';
}
?>

</table>
<p><?php echo $num_movies; ?> Movies</p>
</div>
This is my code for the Database db_ch03-1.php


Code:
<?php
//connect to MySQL
$db = mysql_connect('localhost', 'root', '') or 
    die ('Unable to connect. Check your connection parameters.');

//create the main database if it doesn't already exist
$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query, $db) or die(mysql_error($db));

//make sure our recently created database is the active one
mysql_select_db('moviesite', $db) or die(mysql_error($db));

//create the movie table
$query = 'CREATE TABLE movie (
        movie_id        INTEGER UNSIGNED  NOT NULL AUTO_INCREMENT, 
        movie_name      VARCHAR(255)      NOT NULL, 
        movie_type      TINYINT           NOT NULL DEFAULT 0, 
        movie_year      SMALLINT UNSIGNED NOT NULL DEFAULT 0, 
        movie_leadactor INTEGER UNSIGNED  NOT NULL DEFAULT 0, 
        movie_director  INTEGER UNSIGNED  NOT NULL DEFAULT 0, 

        PRIMARY KEY (movie_id),
        KEY movie_type (movie_type, movie_year) 
    ) 
    ENGINE=MyISAM';
mysql_query($query, $db) or die (mysql_error($db));

//create the movietype table
$query = 'CREATE TABLE movietype ( 
        movietype_id    TINYINT NOT NULL AUTO_INCREMENT, 
        movietype_label VARCHAR(100)     NOT NULL, 

        PRIMARY KEY (movietype_id)
    ) 
    ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));

//create the people table
$query = 'CREATE TABLE people ( 
        people_id         INTEGER UNSIGNED    NOT NULL AUTO_INCREMENT, 
        people_fullname   VARCHAR(255)        NOT NULL, 
        people_isactor    TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, 
        people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, 

        PRIMARY KEY (people_id)
    ) 
    ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));

echo 'Movie database successfully created!';
?>
__________________
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

majormusic is offline
Reply With Quote
View Public Profile Visit majormusic's homepage!
 
 
Register now for full access!
Old 07-28-2009, 10:30 PM Re: I wasn't getting any responses in regards to my database
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
In the select fields from the first example:
movie_name, movie_year, movie_director, movie_leadactor, movietype

You should correct the field name:
movie_name, movie_year, movie_director, movie_leadactor, movie_type
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-30-2009, 08:58 AM Re: I wasn't getting any responses in regards to my database
Extreme Talker

Posts: 206
Name: vikas
Trades: 0
nice observation ...
__________________

Please login or register to view this content. Registration is FREE
Collection of free online books and free ebooks
Please login or register to view this content. Registration is FREE
- Free online pdf books and free pdf eBooks
vikas1234 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I wasn't getting any responses in regards to my database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.54101 seconds with 12 queries