GetDotted Domains

Viewing Thread:
"PHP / mySQL - Help a beginner?"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Thu 04/11/04 at 19:04
Regular
"Picking a winner!"
Posts: 8,502
OK, as part of my final year at uni I have to do an individual project, a rather large one and to start of I need to create a webpage using php and mysql. Won't go into details of what the site has to do as thats not too important right now.
First off the basics.

I've looked at PHP once or twice before, so hopefully that wont be to bad.
Did a bit on SQL ages ago as well as some database work but I'm not sure whats different between SQL and mySQL.

Have downloaded all the stuff for apache, php and mySQL from [URL]http://www.aesthetic-theory.com/learn.php?server2[/URL] and installed before but something went wrong so I'm in the process of installing again just to make sure its all working properly.

Just not sure where to start.
Have a few ebooks to try make things easier but a few things that don't seem to clear....

mySQL files, someone give me an example of one and what the file type they are?

No doubt a few more things will crop up so I'll post them here too :0)

Thanks
Sat 27/11/04 at 16:02
Regular
"Picking a winner!"
Posts: 8,502
Managed to get it going. Think I had made some mistake with one of the tables names. Just deleted the query and started from scratch after populating my tables with loads of data and it worked.

Cheers for the help though.
Sat 27/11/04 at 13:02
Regular
"It goes so quickly"
Posts: 4,083
If MySQL is set up correctly, the SQL query should look up the tables and build a single table on the fly, then return the data as any other query would.

This may be a pain, but can you draw out the database design? For example:

A table
Field A (S) | Field B (N) | Field C (N) | Field D (S)

Another table
Field A (S) | Field B (S) | Field C (S) | Field D (S)

(S) = string.
(N) = numeric.

... or better yet as an image or in Excel. Its been too long since I used MySQL properly I'm afraid.
Sat 27/11/04 at 12:33
Regular
"Picking a winner!"
Posts: 8,502
Had a quick look at it yesterday but it didn't work.
Going to look over the design of my database again just to check things are working as should then give the query another go.
Cheers for the reply
Fri 26/11/04 at 10:52
Regular
Posts: 88
AliBoy wrote:
> I have a database about restaurants, one table about the restaurants
> (names, address etc) I have another table about food categories
> (which is a many to many relationship with restaurant) so another
> table with the primary keys (restaurantcategory).
>
> My query is trying to return all the restaurants that are French.
> From what I remember using in SQL I came up with this:
>
> $result = mysql_query("SELECT * FROM restaurant, foodcategory,
> restaurantcategory WHERE restaurantcategory.restaurantID =
> restaurant.restaurantID AND restaurantcategory.categoryID =
> foodcategory.categoryID AND foodCategory.foodcategory = 'French'
> ");
>
>
> But it dosn't work.

Try either:

SELECT * FROM restaurant LEFT JOIN restaurantcategory USING (restaurantID) LEFT JOIN foodcategory USING(categoryID) WHERE foodcategory.foodcategory='French'

or

SELECT * FROM restaurant
LEFT JOIN retaurantcategory ON
restaurant.restaurantID=restaurantcategory.restaurantID
LEFT JOIN foodcategory ON
restaurantcategory.categoryID=foodcategory.categoryID
WHERE foodcategory.foodcategory='French'

Also, you need to make sure the tables are type in in the same case (eg foodCategory or foodcategory) - it doesn't matter on windows but it does on linux.
Thu 25/11/04 at 17:24
Regular
"Picking a winner!"
Posts: 8,502
cjh wrote:

> What type of query(s) are you trying to run?

I have a database about restaurants, one table about the restaurants (names, address etc) I have another table about food categories (which is a many to many relationship with restaurant) so another table with the primary keys (restaurantcategory).

My query is trying to return all the restaurants that are French. From what I remember using in SQL I came up with this:

$result = mysql_query("SELECT * FROM restaurant, foodcategory, restaurantcategory WHERE restaurantcategory.restaurantID = restaurant.restaurantID AND restaurantcategory.categoryID = foodcategory.categoryID AND foodCategory.foodcategory = 'French' ");


But it dosn't work.
Thu 25/11/04 at 11:54
Regular
"It goes so quickly"
Posts: 4,083
I've used the join statement quite a bit in the past, and it was part of my course back in May, though I haven't used them for a few months now. I found using multiple tables to be pretty straight forward though.

What type of query(s) are you trying to run?
Wed 24/11/04 at 19:09
Regular
"Picking a winner!"
Posts: 8,502
Anyone had much experience with using multiple tables in their database and running queries that takes data from more than one table?

Having some bother getting my queries to work, not sure if it is the query thats wrong or if its to do with my joins in the tables...

Looking for some pointers..
Mon 22/11/04 at 17:20
Regular
"Picking a winner!"
Posts: 8,502
All because I didn't put ' ' round the NULL that I was entering.
:0(

Well at least now it works I can move on to bigger and better things. :0)
Mon 22/11/04 at 16:46
Regular
"Picking a winner!"
Posts: 8,502
The extra comma wasn't the problem.
My form is bigger than that so I just took a few of them to use as an example and just forgot to remove the extra comma from the end.

Used the mysql_error() function which mentioned something about the syntax of my insert so I'll just go over that again to see if I can work out whats causing it.

Thanks
Mon 22/11/04 at 16:28
Regular
Posts: 88
AliBoy wrote:

> $query = "INSERT INTO user(userID, first, last, address, town)
> VALUES (3, '$first', '$last', '$address', '$town',)";
> $result = mysql_query($query);

There's a comma there that shouldn't be there (after '$town').

If that doesn't work, you could try adding an "echo mysql_error()" line after the "$result = ..." line to see what errors mysql is reporting.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Excellent support service!
I have always found the support staff to provide an excellent service on every occasion I've called.
Ben
I've been with Freeola for 14 years...
I've been with Freeola for 14 years now, and in that time you have proven time and time again to be a top-ranking internet service provider and unbeatable hosting service. Thank you.
Anthony

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.