Jump to content
MakeWebGames

Recommended Posts

Posted

when converting some v1 files cause im practicing came into this error for car market

Fatal error: Call to a member function query() on a non-object in /home/damagedc/public_html/carmarket.php on line 31

Also with the converting of v1 to v2 seems really easy to do but sometimes those arrays can get annoying cause sometimes you need them and sometimes you dont

Posted

should be somewhere about here

 

function cmarket_index()
{
global $ir,$c,$userid,$h;
print "
Viewing all listings...
<table width=100% border=6> <tr style='background:black'> <th>Seller</th> <th>Car</th> <th>Acceleration Level</th> <th>Handling Level</th> <th>Speed Level</th> <th>Shield Level</th> <th>Price</th> <th>Links</th> </tr>";
$q=$db->query("SELECT cm.*, u.*,ct.* FROM carmarket cm LEFT JOIN users u ON u.userid=cm.cmADDER LEFT JOIN cars_types ct ON ct.carID=cm.cmCAR ORDER BY cmPRICE ASC",$c);
while($r=$db->fetch_rows($q))
{
if($r['cmADDER'] == $userid) { $link = "[url='carmarket.php?action=remove&ID={$r[']Remove[/url]"; } else { $link = "[url='carmarket.php?action=buy&ID={$r[']Buy[/url]"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['carNAME']}</td> <td>{$r['cmACC']}</td> <td>{$r['cmHAN']}</td> <td>{$r['cmSPD']}</td> <td>{$r['cmSHD']} <td>\$".number_format($r['cmPRICE'])."</td> <td>[$link]</td> </tr>";
}
print "</table>";
}

Posted

You need to declare the database variable within the function.

 

function Test() {

$db->query("SELECT blah FROM blah");

}

 

becomes

 

function Test() {
global $db;

$db->query("SELECT blah FROM blah");

}

 

EDIT: You posted before me, so here:

 

function cmarket_index()
{
global $ir,$c,$userid,$h, $db;
print "
Viewing all listings...
<table width=100% border=6> <tr style='background:black'> <th>Seller</th> <th>Car</th> <th>Acceleration Level</th> <th>Handling Level</th> <th>Speed Level</th> <th>Shield Level</th> <th>Price</th> <th>Links</th> </tr>";
$q=$db->query("SELECT cm.*, u.*,ct.* FROM carmarket cm LEFT JOIN users u ON u.userid=cm.cmADDER LEFT JOIN cars_types ct ON ct.carID=cm.cmCAR ORDER BY cmPRICE ASC",$c);
while($r=$db->fetch_rows($q))
{
if($r['cmADDER'] == $userid) { $link = "[url='carmarket.php?action=remove&ID={$r[']Remove[/url]"; } else { $link = "[url='carmarket.php?action=buy&ID={$r[']Buy[/url]"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['carNAME']}</td> <td>{$r['cmACC']}</td> <td>{$r['cmHAN']}</td> <td>{$r['cmSPD']}</td> <td>{$r['cmSHD']} <td>\$".number_format($r['cmPRICE'])."</td> <td>[$link]</td> </tr>";
}
print "</table>";
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...