Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-04-2005, 09:46 AM codeing Problam?
NuWeb.co.uk's Avatar
NuWeb.co.uk is OFFLINE

Posts: 361
Trades: 0
Hey i made this code to read cnstats information for me.
Here it is:
Code:
<?php
mysql_connect("localhost", "main_cnstats", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());

$result = mysql_query("SELECT hits,hosts FROM cns_counter") 
or die(mysql_error()); 

while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row
echo "<b>Todays Visitors:</b> ".$row['hosts']. "<br><b>Todays Hits:</b> ".$row['hits']. "<br>";
} 
?>
But when i put it in on my website, when i go to look at the games on my website i get the error:

Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/main/public_html/v2/includes/browse.php on line 64
This is like 64 of browse.php and a line above and bellow it:
Code:
$numresults = mysql_query($sql_query); // the query.
$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.
if ($numrows == 0){
__________________

Please login or register to view this content. Registration is FREE


NuWeb 10101101

Last edited by NuWeb.co.uk; 09-04-2005 at 10:01 AM..
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
 
Register now for full access!
Old 09-04-2005, 10:05 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
That error means the SQL query failed. Add an or die(mysql_error()) to that query on line 63, that way when it fails you see the MySQL error telling you what went wrong instead of the PHP error that tells you that 'something went wrong but I won't tell you what'.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 09-04-2005, 10:14 AM
NuWeb.co.uk's Avatar
NuWeb.co.uk is OFFLINE

Posts: 361
Trades: 0
ok, did that now i get the error:
Code:
Parse error: parse error, unexpected T_LOGICAL_OR in /home/main/public_html/v2/includes/browse.php on line 63
But on 63 i put
Code:
or die(mysql_error())
__________________

Please login or register to view this content. Registration is FREE


NuWeb 10101101
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
Old 09-04-2005, 11:01 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
What I meant was that your query should look like this:

PHP Code:
$numresults mysql_query($sql_query) or die(mysql_error()); 
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 09-04-2005, 12:28 PM
NuWeb.co.uk's Avatar
NuWeb.co.uk is OFFLINE

Posts: 361
Trades: 0
now the error is:
Quote:
Table 'main_cnstats.games' doesn't exist
But the table aint even called that its called.
main_cnstats

As it says in the connect info. why it think .games should be on the back of it? .. makeing no sence.
__________________

Please login or register to view this content. Registration is FREE


NuWeb 10101101
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
Old 09-04-2005, 03:14 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
What is in $sql_query when the query is executed? I'm guessing you have something like
Code:
SELECT * FROM main_cnstats.games
when it should be
Code:
SELECT games from main_cnstats
check your $sql_query variable has the right stuff in it.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to codeing Problam?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17019 seconds with 12 queries