Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2006, 04:44 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default An error that has been repeated many times over

Hi,
sorry for my bad eng.
I try to use code chapter6, file: index.php.
----------------------------------------------------------------------
<?php
  $link = mysql_connect("localhost", "bp5am", "bp5ampass")
    or die("Could not connect: " . mysql_error());
  mysql_select_db('moviesite', $link)
    or die(mysql_error());
?>
<html>
<head>
<title>Movie database</title>
<style type="text/css">
TD{color:#353535;font-family:verdana}
TH{color:#FFFFFF;font-family:verdana;background-color:#336699}
</style>
</head>
<body>
<table border="0" width="600" cellspacing="1" cellpadding="3"
       bgcolor="#353535" align="center">
  <tr>
    <td bgcolor="#FFFFFF" colspan="2" align="center">
      Movies <a href="movie.php?action=add&id=">[ADD]</a>
    </td>
  </tr>
<?php
  $moviesql = "SELECT * FROM movie";
  $result = mysql_query($moviesql)
    or die("Invalid query: " . mysql_error());
  while ($row = mysql_fetch_array($result)) {
?>
  <tr>
    <td bgcolor="#FFFFFF" width="50%">
      <?php echo $row['movie_name']; ?>
    </td>
    <td bgcolor="#FFFFFF" width="50%" align="right">
      <a href="movie.php?action=edit&id=<?php
        echo $row['movie_id']; ?>">[EDIT]</a>
      <a href="delete.php?type=movie&id=<?php
        echo $row['movie_id']?>">[DELETE]</a>
    </td>
  </tr>
<?php
  }
?>
  <tr>
    <td bgcolor="#FFFFFF" colspan="2" align="center">
      People <a href="people.php?action=add&id=">[ADD]</a>
    </td>
  </tr>
<?php
  $moviesql = "SELECT * FROM people";
  $result = mysql_query($moviesql)
    or die("Invalid query: " . mysql_error());
  while ($row = mysql_fetch_array($result)) {
?>
  <tr>
    <td bgcolor="#FFFFFF" width="50%">
      <?php echo $row['people_fullname']; ?>
    </td>
    <td bgcolor="#FFFFFF" width="50%" align="right">
      <a href="people.php?action=edit&id=<?php
        echo $row['people_id']; ?>">[EDIT]</a>
      <a href="delete.php?type=people&id=<?php
        echo $row['people_id']; ?>">[DELETE]</a>
    </td>
  </tr>
<?php
  }
?>
</table>
</body>
</html>
----------------------------------------------------------------------

But i incur in this type of error:

Warning: mysql_connect(): Accesso non consentito per l'utente: 'bp5am'@'localhost' (Password: SI) in c:\programmi\easyphp1-8\www\a1db\index.php on line 2
Could not connect: Accesso non consentito per l'utente: 'bp5am'@'localhost' (Password: SI)

A forbidden access.
I think there is a problem with db creation. I use code chapter3 to create db.
----------------------------------------------------------------------
<?php
//connect to MySQL; note we've used our own parameters- you should use
//your own for hostname, user, and password
$connect = mysql_connect("localhost", "root", "mysqlpass") or
     die ("Hey loser, check your server connection.");

//create the main database
mysql_create_db("wiley")
     or die(mysql_error());

//make sure our recently created database is the active one
mysql_select_db ("wiley");

//create "movie" table
$movie = "CREATE TABLE movie (
  movie_id int(11) NOT NULL auto_increment,
  movie_name varchar(255) NOT NULL,
  movie_type tinyint(2) NOT NULL default 0,
  movie_year int(4) NOT NULL default 0,
  movie_leadactor int(11) NOT NULL default 0,
  movie_director int(11) NOT NULL default 0,
  PRIMARY KEY (movie_id),
  KEY movie_type (movie_type,movie_year)
) TYPE=MyISAM AUTO_INCREMENT=4 ";

$results = mysql_query($movie)
     or die (mysql_error());

//create "movietype" table
$movietype = "CREATE TABLE movietype (
  movietype_id int(11) NOT NULL auto_increment,
  movietype_label varchar(100) NOT NULL,
  PRIMARY KEY (movietype_id)
) TYPE=MyISAM AUTO_INCREMENT=9" ;

$results = mysql_query($movietype)
     or die(mysql_error());

//create "people" table
$people = "CREATE TABLE people (
  people_id int(11) NOT NULL auto_increment,
  people_fullname varchar(255) NOT NULL,
  people_isactor tinyint(1) NOT NULL default 0,
  people_isdirector tinyint(1) NOT NULL default 0,
  PRIMARY KEY (people_id)
) TYPE=MyISAM AUTO_INCREMENT=7";

$results = mysql_query($people)
     or die(mysql_error());

echo "Movie Database successfully created!";

?>
----------------------------------------------------------------------

Another problem are some variable don't dichiarate...i forget some option to edit in file php?

I hope in a exaurient reply =)
Cya
Tano
 
Old October 31st, 2006, 06:05 PM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hi Tano,

this sounds like a mysql privileges problem. Use the command line client to log in and do:

Code:
mysql> GRANT ALL ON wiley.* TO 'bp5am'@'localhost' IDENTIFIED BY 'bp5ampass';
0 rows affected
mysql> FLUSH PRIVILEGES;
--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset repeated values Narts C# 1 November 23rd, 2007 10:31 AM
matches without repeated items pongup BOOK: Beginning Regular Expressions 0 April 7th, 2007 09:05 PM
How can I stop repeated words elfstoneUK BOOK: Beginning Regular Expressions 1 September 8th, 2006 03:04 AM
How to delete repeated records in a query ramk_1978 SQL Language 11 March 15th, 2005 10:06 AM
Excecuting repeated code every one second maxpotters Excel VBA 6 March 6th, 2005 06:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.