hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : need mysql help ASAP
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

need mysql help ASAP

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-05-2007, 03:58 AM
mikey1090 mikey1090 is offline
Web Hosting Evangelist
 
Join Date: Feb 2006
Location: Lancashire, UK
Posts: 472

need mysql help ASAP


I have a game, and in that game players are in teams. 2 queries are not working. 1 query to show the score rankings on the whole game, and one to show people land and score for just people in your team.

I have the following tables

A table called game, storing username pass etc

a table called res, storing players land and resources

a table called score to hold their score

a table called team to hold their teamid (if they are not in a team, teamid is 1)

a table called teams to hold details about each team (leader, temname team bank etc)

I ran query to select those fields from the table, i did not get a mysql_error() from it, but its showing the wrong data

Before i added the whole team aspect to it, it worked fine.

The where clause is WHERE game.id=res.id AND res.id=score.id AND team.id=game.id AND teams.teamid=team.teamid


But it shows the incorrect teamname


can anyone help me please?

Mike

Reply With Quote


Sponsored Links
  #2  
Old 02-05-2007, 08:57 AM
mitchlrm mitchlrm is offline
Junior Guru
 
Join Date: Dec 2004
Location: San Francisco Bay Area
Posts: 213
It is fairly impossible to help without a listing of your database definitions that shows primary and foreign keys.

__________________
Sizzling Web Design - Creator of EasyEstimates: Let your customers create complex estimates and orders on your web site.
Video Gallery Pro - Show your videos like a pro

Reply With Quote
  #3  
Old 02-05-2007, 09:21 AM
zacharooni zacharooni is offline
Community Guide
 
Join Date: Apr 2005
Posts: 1,214
Put your code in tags, and put it here so we can help you. Obviously take out passwords and such.

Reply With Quote
Sponsored Links
  #4  
Old 02-05-2007, 09:40 AM
mikey1090 mikey1090 is offline
Web Hosting Evangelist
 
Join Date: Feb 2006
Location: Lancashire, UK
Posts: 472
The following are all primary keys, and are based on the users Userid (like a foreighn key in each table)

Code:
game.id
score.id
res.id
team.id
They are INT (11)

The WHERE clause of the query is intended to display user accounts order by score, and display their team name based on the teamid in the team table.

PHP Code:
$result=mysql_query("SELECT
game.id,game.username,res.id,res.mineone,res.minetwo,score.score,team.id,
team.teamid,teams.teamname,teams.teamid
WHERE game.id=res.id AND res.id=score.id AND team.id=game.id AND teams.teamid=team.teamid AND game.id=score.id AND score.id=team.id"
) or die(mysql_error()); 

better?


Last edited by mikey1090; 02-05-2007 at 09:43 AM.
Reply With Quote
  #5  
Old 02-06-2007, 01:30 PM
jimpoz jimpoz is offline
WHT Addict
 
Join Date: Sep 2004
Posts: 105
You're missing the FROM clause in your query.
PHP Code:
$result=mysql_query("SELECT
game.id,game.username,res.id,res.mineone,res.minetwo,score.score,team.id,
team.teamid,teams.teamname,teams.teamid
FROM game, res, score, team, teams
WHERE game.id=res.id AND res.id=score.id AND team.id=game.id AND teams.teamid=team.teamid AND game.id=score.id AND score.id=team.id"
) or die(mysql_error()); 

Reply With Quote
  #6  
Old 02-06-2007, 02:18 PM
mikey1090 mikey1090 is offline
Web Hosting Evangelist
 
Join Date: Feb 2006
Location: Lancashire, UK
Posts: 472
that wasnt the actual query, that was me writing quickly to show an example

i managed to fix it, there was some data missing from a table so it messed up which records where shown

mike

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Parallels Now Offering Licenses for CloudLinux OS Web Hosting News 2011-10-26 17:29:25
Web Hosting Sales and Promos Roundup - October 7, 2011 Web Hosting News 2011-10-07 19:56:18
Web Hosting Software Firm CloudLinux Releases CloudLinux OS Version 6.1 Web Hosting News 2011-09-13 14:08:49
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?