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 February 3rd, 2011, 04:29 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create db

Hei!

This is what my error-message is "4 5.1.44Zm7f}e_-ÿ÷_w[Aq7ZC}o6]ÿ„Got packets out of order".

My localhost port-number is :8888 when running scripts, but as far as I can see it is :8889 when it comes to MySql. The connection goes well, but the creation of the db is not so well.

How (in what file) do I change to :8888 for MySql if that is the solution?

This is what I have got:

Code:


//Koble til databasen
	$connect = mysql_connect("localhost", "root", "root") or
		die("Sjekk databaseoppkoblingen!");

//lager hoveddatabasen
	$create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite") or
		die(mysql_error());

But when I did some change to the hole script and reduced the number of tables to be created (and // eliminate one line!), left out the creation of a new db, then it went ok... Please take a look and comment;

Code:
//Tilkobling og valg av database

$connection = mysql_connect("localhost", "root", "root");
mysql_select_db("some_db", $connection);

//Sette en sql-spørring mot db

//Lage movie-tabellen
$movie = "CREATE TABLE movie (";
$movie .= " movie_id int ( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,";
$movie .= " movie_name VARCHAR ( 255 ) NOT NULL,";
$movie .= " movie_type TINYINT ( 2 ) NOT NULL DEFAULT 0,";
$movie .= " movie_year INT ( 4 ) NOT NULL DEFAULT 0,";
$movie .= " movie_leadactor INT ( 11 ) NOT NULL DEFAULT 0,";
$movie .= " movie_director INT ( 11 ) NOT NULL DEFAULT 0,";
//$movie .= " KEY movie_type (movie_type, movie year);
$movie .= ")";

mysql_query($movie, $connection);
echo $movie;
But I am not quite shure about what changes which are in place in order to make it work?! Has this to do with the version-no of my PHP? And also: what is this line ment to do?

Code:
//$movie .= " KEY movie_type (movie_type, movie year);

Establish a relation between to tables? How can I solve this now if that is the case?

Hmmm... it seems that some of the solution (with my MySql ver 5.1.44) are:

Code:
$create = mysql_query("CREATE DATABASE moviesite") or
die(mysql_error());

//The "IF NOT EXISTS" is left out and the line which was commented out previously was missing the ,"; at the end! Puuuhh!

$movie .= " KEY movie_type (movie_type, movie year),";
Regards,
grstad
__________________
Internet has become favorable with that tool...thank you Tim Berners-Lee!

Last edited by grstad; February 4th, 2011 at 06:47 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to create new table in DB Explorer eddiemcham BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 May 29th, 2009 06:03 PM
Don't know how to execute sql script to create DB saxomopho BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 May 29th, 2007 12:09 PM
Use DTS to create new MS Access DB? anya SQL Server DTS 2 February 25th, 2005 10:24 AM
Create drop down list from SQL DB lshamba Classic ASP Databases 2 August 26th, 2004 10:49 PM
how to create db user? ram_siddinen SQL Server 2000 2 January 30th, 2004 06:34 AM





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