ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 13th, 2004, 07:41 PM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
2 problems

ok i got these 2 problems that ive been working on and i cannot solve. here is the site url HERE

ok my first problem is on that page there.
now you see how when you scroll through the prices and it keeps showing you some games over?? well before that code worked for that but that was with a simpler query, when i use inner join it does that for some reason...

the code to that page is attached.



ok now my second problem is really something i havent used in a while, now you see where the news is posted, well a while ago i used a script in a similar page to shorten it to something like this

"this is an example news po......."

but havent been able to find that bit of code even tho ive searched the forums and my pc for hours.....

<cfif "#FORM.terms#" is "0" and "#session.termsaccept#" is "0">
<cfset "type" = "1">
<cfinclude template="terms2.cfm">
<cfelse>
<cfset "session.termsaccept" = "1">

<cfparam name="startrow" default="1">

<cfquery datasource="#datasourcename#" name="mcatlist" blockfactor="100">
SELECT games.ID As MID, games.gamename, games.gameimage, players_prices.ID As CID, players_prices.players, players_prices.price
FROM games Inner Join players_prices On games.ID = players_prices.gameid
ORDER BY games.gamename, players_prices.players
</cfquery>
<cfquery name="gameslist" blockfactor="100" datasource="#datasourcename#">
SELECT *
FROM games
ORDER BY gamename
</cfquery>
<cfset totalrows = 0>
<table width="*" border="0" cellspacing="0" cellpadding="0" class="normal_text">
<cfoutput query="mcatlist" group="MID" startrow="#startrow#" maxrows="3">
<cfquery name="priceselect" datasource="#datasourcename#" blockfactor="100">
SELECT *
FROM players_prices
WHERE gameid = #MID#
</cfquery>
<tr>
<td width="30"></td>
<td>
<img src="images/games/#gameimage#" alt="#gamename#" height="120" width="240">
<div class="spacer">&nbsp;</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>#gamename#</strong>
</td>
<td>
<table width="*" border="0" cellspacing="0" cellpadding="0" class="normal_text">
<tr>
<td width="15"></td>
<td>Players:&nbsp;&nbsp;&nbsp;&nbsp;</td><td><cfset "playercount" = "1"><cfoutput group="CID">#players#<cfif "playercount" is not "#priceselect.recordcount#"> | </cfif><cfset "playercount" = #playercount# + 1></cfoutput></td>
</tr>
<tr>
<td width="15"></td>
<td height="1" colspan="2" bgcolor="666666"></td>
</tr>
<tr>
<td width="15"></td>
<td>Prices: </td><td><cfset "pricecount" = "1"><cfoutput group="CID">#price#<cfif "#pricecount#" is not "#priceselect.recordcount#"> | </cfif><cfset "pricecount" = #pricecount# + 1></cfoutput></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3" height="20"></td>
</tr>
<cfset totalrows = #recordcount#>
</cfoutput>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0" class="normal_text">
<tr>
<td align="left"><cfif "#startrow#" gte "4">
<cfset prevnumber = #startrow# - 5>
<cfoutput>
<a href="index.cfm?pageid=prices&startrow=#prevnumber#"><< Prev 3 Games</a>
</cfoutput>
</cfif> </td>
<td align="right"><cfset endnumber = #startrow# + 2>
<cfif "#totalrows#" gt "#endnumber#">
<cfset nextnumber = #startrow# + 5>
<cfoutput>
<a href="index.cfm?pageid=prices&startrow=#nextnumber#">Next 3 Games >></a>
</cfoutput>
</cfif></td>
</tr>
<tr>
<td colspan="2" height="20"></td>
</tr>
</table>
</cfif>

Reply With Quote
  #2  
Old October 13th, 2004, 10:23 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
To truncate a string use the left() function.

Your URL did not go through so I can't see the error, but regarding the code that you posted: You may want to try using DISTINCT in your SELECT statement.

I know you're new to this, so I'd like to mention that you're violating several best-practices in this code. Just a few that you may want to explore as you learn further:
  • Don't need quote marks around variable names
  • Unnecessary pound signs
  • Unnecessary quote marks around numeric values
  • Setting SESSION variables without considering locking
  • Mixing queries and presentation code
  • Looping over one query and running another query (almost always means these should be combined)
  • SELECT only the columns you need by name instead of SELECT *
  • Using variables in SQL statements that are unprotected from SQL injection attacks. Use <cfqueryparam>.

Hope that's helpful.

Regards,

Brian
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old October 13th, 2004, 10:35 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 186 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 22 m 55 sec
Reputation Power: 0
i may be kicking a dead horse here but you're script is very messy man...thats cool if you dont want others that work with u to be able to read it, but for that you should just make custom tags or even CFINCLUDE the good stuff.

Hope that helps...If ive only slighlty annoyed you well then...Too bad.

PS. seriously though im serious

Reply With Quote
  #4  
Old October 14th, 2004, 03:40 AM
iyad muhanna iyad muhanna is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 7 iyad muhanna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I would have to agree, even if no one else is working on the code, it makes it much easier to debug yourself when its a bit clean, includes are ok but harder to debug though. I usually use indentations:

<cfif ....>
<cfquery ....>
SELECT
.....
</cfquery ....>
</cfif ....>

It does get pretty long sometimes though

Reply With Quote
  #5  
Old October 14th, 2004, 03:41 AM
iyad muhanna iyad muhanna is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 7 iyad muhanna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it didnt show my spaces i put to make it look nice

Reply With Quote
  #6  
Old October 15th, 2004, 04:06 AM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
oh sorry about that the link to the page is http://www.socgaming.net/newsite/index.cfm?pageid=prices

when you go there click accept in terms and then click "next 3 games" and you will see it shows some games over for some reason.....

Reply With Quote
  #7  
Old October 15th, 2004, 04:08 AM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
also the code is not very messy, its just that this forum took the spaces out....

Reply With Quote
  #8  
Old October 15th, 2004, 11:55 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Quote:
Originally Posted by Panther893
oh sorry about that the link to the page is http://www.socgaming.net/newsite/index.cfm?pageid=prices

when you go there click accept in terms and then click "next 3 games" and you will see it shows some games over for some reason.....
Did you add DISTINCT to the query as I suggested?

Reply With Quote
  #9  
Old October 15th, 2004, 02:48 PM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 810 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 20 m 11 sec
Reputation Power: 56
Send a message via MSN to Panther893
yes i did, but it still keeps doing the thing, i think it has something to do with the startrow in the cfoutput tag..... im just not sure what it could be..........

Reply With Quote
  #10  
Old October 17th, 2004, 04:31 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Unfortunately I don't either because there's no way for me to execute the code. I'd try stripping out all the extraneous code and try to isolate the problem itself (take out the tables, etc.).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > 2 problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |