Jump to content

Cannot instantiate non-existent class


oliveralden

Recommended Posts

Hi there.  I'm fairly new to PHP, and am trying to integrate a shopping cart code with my template.  I seem to have a header problem which I can't quite solve.

Here's the error:
Fatal error: Cannot instantiate non-existent class: mysql in /home/weirdore/public_html/cartjune/cart-demo/inc/global.inc.php on line 6

And here's the code, up to the end of the header & title:
-----------------------------------------------------------------------------------------------------
<?php
session_start();
require_once('http://www.weirdorecords.com/cartjune/functions.inc.php');
require_once('http://www.weirdorecords.com/cartjune/global.inc.php');
require_once('http://www.weirdorecords.com/cartjune/mysql.class.php');
$cart = $_SESSION['cart'];
$action = $_GET['action'];
switch ($action) {
case 'add':
if ($cart) {
$cart .= ','.$_GET['id'];
} else {
$cart = $_GET['id'];
}
break;
case 'delete':
if ($cart) {
$items = explode(',',$cart);
$newcart = '';
foreach ($items as $item) {
if ($_GET['id'] != $item) {
if ($newcart != '') {
$newcart .= ','.$item;
} else {
$newcart = $item;
}
}
}
$cart = $newcart;
}
break;
case 'update':
if ($cart) {
$newcart = '';
foreach ($_POST as $key=>$value) {
if (stristr($key,'qty')) {
$id = str_replace('qty','',$key);
$items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart);
$newcart = '';
foreach ($items as $item) {
if ($id != $item) {
if ($newcart != '') {
$newcart .= ','.$item;
} else {
$newcart = $item;
}
}
}
for ($i=1;$i<=$value;$i++) {
if ($newcart != '') {
$newcart .= ','.$id;
} else {
$newcart = $id;
}
}
}
}
}
$cart = $newcart;
break;
}
$_SESSION['cart'] = $cart;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><!-- InstanceBegin template="/Templates/frontpage.dwt" codeOutsideHTMLIsLocked="false" -->
<head><meta name="description" content="Weirdo records sells experimental recordings on lp, cd, cdr, & cassette.  We love noise kids, psychedelic freaks, retards banging on kitchen pots, ultra-snobby longhairs & many other types of record collecting nerds.">
<meta name="keywords" content="weirdo records werido weird noise cd lp cds lps rock psychedelic avant garde wolf eyes lightning bolt improv experimental volcanic forced music sounds recordings">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Welcome to Weirdo Records</title>
------------------------------------------------------------------------------------------------------

I'm using Dreamweaver & Windows xp, & a webhosting server.  The code does work without the template, but whenever I try to patch them together I've run into this problem.  Any suggestions would be greatly appreciated.  Thanks for your time.

-Oliver Alden
Link to comment
Share on other sites

Well, I *think* I understand what you're saying.  However, it doesn't seem to matter what order I use for those 3 include files, I still get the same error message.  The global.inc.php, by the way, just uses $ to define host, user, pass, dbname.  So I don't think the error is within that file.  Any other ideas from anyone?  Thanks.
Link to comment
Share on other sites

This line...
[code=php:0]
$db = &new MySQL($host,$user,$pass,$name);
[/code]
is where you are trying to instantiate the class MySQL, which I can only assume is defined within mysql.class.php. You need to include mysql.class.php before global.inc.php.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.