Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
welshguy21 is on a distinguished road
 
Posts: 18
Join Date: May 2011
Default Newbie help - 05-15-2011, 08:22 PM

http://fifagoldrush.comxa.com/

Uploaded all my files using a ftp manager

Put my details into setup file

// database
$database = mysql_connect("localhost", "a1435729_fifa", "j*****");
mysql_database = "a1435729_fifa";

You can see the errors i'm getting any ideas on how i fix them ?
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
lobrc's Avatar
Administrator
lobrc is on a distinguished road
 
Posts: 5,037
Join Date: Jan 2010
Location: http://www.lobrc.net
Default 05-15-2011, 09:25 PM

Don't use localhost. You can find the correct server in your cpanel when you click MySQL.


FREE SCRIPT INSTALLATION SERVICE | PREMIUM HOSTING* | LOBRC.NET

*All packages include Quality Support, Website Builder, Free Site Migration, 30 Day Money Back Guarantee, Official cPanel and Fantastico Autoinstaller.

Plus get 20% off with promo code 000WH20. Contact sales for more information.
Reply With Quote
(#3 (permalink))
Old
Junior Member
welshguy21 is on a distinguished road
 
Posts: 18
Join Date: May 2011
Default 05-15-2011, 09:27 PM

Thanks.

Thats one problem sorted just need to find out why i have other errors
Reply With Quote
(#4 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 735
Join Date: Dec 2010
Default 05-16-2011, 01:29 AM

Can you show us your codes around line 10, line 27, line 447 and line 449 of function.php file? Usually, the error
message 'supplied argument is not a valid ....' is displayed in case of no table, wrong selection of db or
wrong query.

By the way, did you change the background of error message box to dark color so that visitors cannot
see the message?

Last edited by grace1004; 05-16-2011 at 01:38 AM.
Reply With Quote
(#5 (permalink))
Old
Junior Member
welshguy21 is on a distinguished road
 
Posts: 18
Join Date: May 2011
Default 05-16-2011, 10:09 AM

No its a website template that i have been given so i havnt changed anything yet. I want to get it working and then change the graphics etc to work for my fifa website.

I will look for the information you have requested once i get back to my computer later thanks
Reply With Quote
(#6 (permalink))
Old
Junior Member
welshguy21 is on a distinguished road
 
Posts: 18
Join Date: May 2011
Default 05-16-2011, 02:52 PM

These are the current errors i'm having :

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/a1435729/public_html/functions.php on line 10

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/a1435729/public_html/functions.php on line 19

Warning: Invalid argument supplied for foreach() in /home/a1435729/public_html/footer.php on line 23




First few lines of the function.php



PHP Code:
<?php

// ---------------------------------
//    SQL Functions
// ---------------------------------

// get single value
function sql_fetch_single($query)
{
    
$result mysql_fetch_row(mysql_query($query));
    
    return 
$result[0];
}

// get multi-dimensional array
function sql_fetch_array($query)
{
    
$sql mysql_query($query);
    while (
$p mysql_fetch_assoc($sql)){$return[] = $p;}
    
    return 
$return;
}

function 
sql_fetch_numerical_array($query)
{
    
$sql mysql_query($query);
    while (
$p mysql_fetch_row($sql)){$return[] = $p[0];}

    return 
$return;
}

function 
sql_fetch_rows($query)
{
    
$sql mysql_query($query);
    while (
$p mysql_fetch_row($sql)){$return[] = $p;}

    return 
$return;
}

Last edited by lobrc; 05-16-2011 at 05:15 PM. Reason: PHP tags added
Reply With Quote
(#7 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 735
Join Date: Dec 2010
Default 05-16-2011, 10:56 PM

Please change your code as follows:

Code:
$conn = mysql_connect("host", "mysql_user", "mysql_pass"); //use actual values
mysql_select_db("db_name", $conn); //use actual values 

// get single value
function sql_fetch_single($query)
{
$result = mysql_fetch_row(mysql_query($query,$conn));    
return $result[0];
}

//if not working, change to:
{
$result = mysql_query($query, $conn);
$row = mysql_fetch_row($result);
return $row[0];
}

// get multi-dimensional array
function sql_fetch_array($query)
{
$sql = mysql_query($query, $conn);
while($p = mysql_fetch_asso($sql)) {$return[]=$p;}
return $return;
}
//if not working change to:
{
$sql = mysql_query($query, $conn);
while($p = mysql_fetch_asso($sql)) {return $p[]; }
}
For error message displayed on line 23, I need to see the code for footer.php.

Last edited by grace1004; 05-16-2011 at 10:59 PM.
Reply With Quote
(#8 (permalink))
Old
Junior Member
welshguy21 is on a distinguished road
 
Posts: 18
Join Date: May 2011
Default 05-17-2011, 12:13 AM

Thanks very much.

Is there anywhere on this forum to donate as a thank you or even to yourself for the support ?


Footer PHP

</div>

<div class="clearer"></div>

</div>

</div>

<div class="bottom">

<div class="content">

<div class="left">

<h3>Latest results » <a href="/results/" title="More results">more</a></h3>
<table class="datatable">
<tr class="bold">
<td>Date</td>
<td>Game</td>
<td style="width: 40px; text-align: center">Bets</td>
<td style="text-align: right">Total</td>
</tr>
<?php $c=0; foreach (getGames('type=history|limit=5') as $result) : $c++ ?>
<tr<?=$c%2?' class="odd"':'';?>>
<td><?=date("d/m",$result["expiration"]);?></td>
<td><a href="/game/<?=$result["gid"];?>/" title="View game details"><?=str_cut($result["game_title"], 38);?></a> <?php if ($authed && $betting_user["level"] > 0 && $result["winner"] == 0) : ?> ~ <a href="/admin_game.php?id=<?=$result["gid"];?>" title="Edit game details">edit</a><?php endif;?></td>
<td style="text-align: center"><a href="/game/<?=$result["gid"];?>/#bets" title="View bets"><?=$result["bets"];?></a></td>
<td style="text-align: right">$<?=$result["bet_amount"];?></td>
</tr>
<?php endforeach;?>
</table>

</div>

<div class="right">
Reply With Quote
(#9 (permalink))
Old
Junior Member
welshguy21 is on a distinguished road
 
Posts: 18
Join Date: May 2011
Default 05-17-2011, 02:51 AM

Final error once footer is done is this one:

Warning: Invalid argument supplied for foreach() in /home/a1435729/public_html/functions.php on line 403

This roughly around line 403 i believe

/ ---------------------------------
// math
// ---------------------------------


function calcOdds($bets,$totalbets,$total_options){
return round(($total_options + $totalbets) / (1 + $bets),1);
}

function percentage($this,$total,$max)
{
$maxwidth = 200;
$width = round(($this/$total)/($max/$total) * $maxwidth);

return '<div class="percentage" style="width: '.$width.'px"><span></span></div>';
}

function time2days($time){
return round((time()-$time)/(3600*24)) + 1;
}

function timeleft($time)
{
$diff = $time - time();

$hour = 3600;
$day = $hour*24;
$week = $day*7;

if ($diff < $day)
{
$h = floor($diff/$hour); $diff -= $h*$hour;
$m = floor($diff/60); $diff -= $m*60;

if ($h > 0) return $h . 'h ' . $m . 'm ' . $diff . 's';
elseif ($m > 0) return $m . 'm ' . $diff . 's';
else return $diff . ' seconds';
}
else if ($diff < $week)
{
$d = floor($diff/$day); $diff -= $d*$day;
return $d . 'd' . ' ' . floor($diff/$hour) . 'h';
}
else {
return floor($diff/$day) . ' days';
}
}

// generate tag cloud
function tagCloud($items,$divider,$max_value)
{
global $betting;

foreach ($items as $item)
$total += $item["bets"];


foreach ($items as $item)
{
$size = $betting["cloud_min_size"] + round(($item["bets"]/$total)/($max_value/$total) * $betting["cloud_max_size"]);

$cloud[] = '<span style="font-size: '.$size.'px;"><a href="/game/'.$item["gid"].'/" title="View game details ('.$item["bets"].' bets)">'.$item["game_title"].'</a></span>';
}

return implode($divider,$cloud);
}

// get data and generate tag cloud
function getCloud($divider)
{
$max_value = sql_fetch_single("SELECT COUNT(bid) AS c FROM betting_game JOIN betting_options ON game = gid JOIN betting_bets on opt = oid WHERE expiration > ".time()." GROUP BY gid ORDER BY c DESC LIMIT 1");

$items = sql_fetch_array("SELECT gid,game_title,name AS tournament_name,COUNT(bid) AS bets,prefix FROM betting_game JOIN betting_options ON gid = game JOIN betting_bets ON opt = oid LEFT JOIN schedule_tournaments ON id = tournament WHERE expiration > ".time()." GROUP BY gid");

return tagCloud($items,$divider,$max_value);
}

// ---------------------------------
// error(s)
// ---------------------------------

function page_error()
{
$_SESSION["error_url"] = $_SERVER["SCRIPT_URI"];

header("Location: /error.php");
exit();
}
function go($url='/')
{
header('Location: ' . $url);
exit();
}
function reload(){
go($_SERVER['REQUEST_URI']);
}


// ---------------------------------
// global qwdrama stuff
// ---------------------------------

function getProfile($uid){
return sql_fetch("SELECT name,born,email,website,irc,clan FROM drama_user JOIN betting_users ON drama_user = uid WHERE uid = $uid LIMIT 1");
}

// ---------------------------------
// goldrush statistics
// ---------------------------------

function updateStats(&$var)
{
$var["stats"]["upcoming_games"] = sql_fetch_single("SELECT COUNT(*) FROM betting_game WHERE expiration > " . time());
$var["stats"]["pending_games"] = sql_fetch_single("SELECT COUNT(*) FROM betting_game WHERE (expiration < " . time() . " AND winner = 0)");
$var["stats"]["played_games"] = sql_fetch_single("SELECT COUNT(*) FROM betting_game WHERE winner != 0");
$var["stats"]["active_bets"] = sql_fetch_single("SELECT COUNT(*) FROM betting_bets JOIN betting_options ON oid = opt JOIN betting_game ON gid = game WHERE expiration > " . time());

/*
$var["stats"]["pending_bets"] = sql_fetch_single("SELECT COUNT(*) FROM betting_bets JOIN betting_options ON oid = opt JOIN betting_game ON gid = game WHERE (expiration < " . time() . " AND winner=0)");

$var["stats"]["registered_users"] = sql_fetch_single("SELECT COUNT(*) FROM betting_users");
$var["stats"]["total_bets"] = sql_fetch_single("SELECT COUNT(*) FROM betting_bets");
$var["stats"]["total_bet_amount"] = sql_fetch_single("SELECT SUM(bet) FROM betting_bets");
$var["stats"]["total_games"] = sql_fetch_single("SELECT COUNT(*) FROM betting_game");

$var["stats"]["biggest_win"] = sql_fetch("SELECT h_game,MAX(h_change) AS amount,uid,alias FROM betting_history JOIN drama_user ON uid = h_user WHERE h_type = 'bet' GROUP BY h_user,h_game ORDER BY amount DESC LIMIT 1");
$var["stats"]["biggest_loss"] = sql_fetch("SELECT h_game,MIN(h_change) AS amount,uid,alias FROM betting_history JOIN drama_user ON uid = h_user WHERE h_type = 'bet' GROUP BY h_user,h_game ORDER BY amount ASC LIMIT 1");
*/
}

// ---------------------------------
// SEO
// ---------------------------------
function generate_keywords($title)
{
$title = preg_replace('/[^\\w]/', ' ', $title);
$title = explode(" ", $title);
$title = array_unique($title);
$title = implode(",", $title);
$title = preg_replace('/,{2,}/', ',', $title);
$title = strtolower($title);
return $title;
}


// pagination
function paginate($item_count)
{
global $browse;

if ( $item_count <= $browse["per_page"] ) {
return false;
}
else
{

$base_url = preg_replace('/page\/\\d+\//', '', $_SERVER["REQUEST_URI"]);
$total_pages = ceil( $item_count/$browse["per_page"] );

// pages
if ($total_pages < $browse["show_pages"])
{
$p_start = 1;
$p_end = $total_pages;
}
else
{
$p_start = $browse["page"] - floor(($browse["show_pages"]-1) / 2);

if ($p_start < 1) $p_start = 1;

$p_end = $p_start + $browse["show_pages"] - 1;

if ($p_end > $total_pages)
$p_end = $total_pages;

if (($p_end - $p_start) < $browse["show_pages"])
$p_start = $p_end - ($browse["show_pages"] - 1);
}

$p = $p_start;

while ($p <= $p_end)
{
if ($p == 1)
$page_url = ($p == $browse["page"]) ? '<span class="currentpage">'.$p.'</span>' : '<a href="'.$base_url.'" title="Page ' . $p . '">' . $p . '</a>';
else
$page_url = ($p == $browse["page"]) ? '<span class="currentpage">'.$p.'</span>' : '<a href="'.$base_url.'page/'.$p.'/" title="Page ' . $p . '">' . $p . '</a>';

$pages[] = $page_url;
$p++;
}

$pagination["pages"] = implode(" ", $pages);

if ($p_start > 1)
$pagination["pages"] = '<a href="' . $base_url . '" title="First page">First</a>' . ".." . $pagination["pages"];

if ($p_end < $total_pages)
$pagination["pages"] .= "..";
if ($p_end < $total_pages)
$pagination["pages"] .= '<a href="' . $base_url . 'page/' . $total_pages . '/" title="Last page">Last</a>';

// next & prev link
if ( $browse["page"] > 1 ){
$prev_url = ($browse["page"] == 2) ? $base_url : $base_url . 'page/' . ( $browse["page"]-1 ) . '/';
$pagination["prev"] = '<a href="' . $prev_url . '" title="Previous page"><span class="prev">Previous page</span></a>';
}

if ( $browse["page"] < ($total_pages) )
$pagination["next"] = '<a href="' . $base_url . 'page/' . ( $browse["page"]+1 ) . '/"><span class="next" title="Next page">Next page</span></a>';

$pagination["page_count"] = $total_pages;

return $pagination;
}
}

?>
Reply With Quote
(#10 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 735
Join Date: Dec 2010
Default 05-17-2011, 03:52 AM

In your code, there should be function getGames(), but I could not find it from your
code above. If the file is too long to be quoted, just attache it (Please make fake
data on mysql DB password or other critical information, if there is any in the file).

If my post helped you, you can donate to 000webhost.com on my behalf.
In the process of preparing replies, I also acquire additional knowledge
on php & mysql. That's why I am posting here.
Reply With Quote
Reply

Thread Tools
Display Modes

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




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com