hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : (PHP) Notice: Use of undefined constant
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

(PHP) Notice: Use of undefined constant

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-27-2005, 01:41 AM
Trilogen Trilogen is offline
Newbie
 
Join Date: Sep 2004
Location: Sydney
Posts: 7
Question

(PHP) Notice: Use of undefined constant


I'm a noob here, reading through SAMs PHP & MySQL Web Development. I can't get around this problem.

PHP Code:
$products = array( array("TIR""Tires"100),
        array( 
"OIL""Oil"10),
        array( 
"SPK""Spark Plugs"4));

function 
compare($x$y)
{
    if ( 
$x[1] == $y[1] )
        return 
0;
    else if ( 
$x[1] < $y[1] )
        return -
1;
    else
        return 
1;
}

usort($productscompare); 
I'ts supposed to sort the arrays inside $products

Outputs:

Notice: Use of undefined constant compare - assumed 'compare' in C:\Inetpub\wwwroot\PHP\usort.php on line 16

Reply With Quote


Sponsored Links
  #2  
Old 01-27-2005, 02:05 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
Change to usort($products, 'compare');

Any string not encapsulated in quotes is considered a constant, and that message is just a Notice telling you that PHP thinks compare is a constant, but its not defined anywhere.

__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise

Reply With Quote
  #3  
Old 01-27-2005, 02:28 AM
Trilogen Trilogen is offline
Newbie
 
Join Date: Sep 2004
Location: Sydney
Posts: 7
That did the trick, thanks fyre!

Reply With Quote
Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Hosting Direct Suing ISP, says Orcon Cut Off 9,300 Customer Sites Web Hosting News 2012-07-20 10:43:58
A Cool DMCA Takedown Flowchart from Web Host Nexess Blog 2012-02-29 18:00:18
Bit lockers and the DMCA Blog 2011-12-15 17:14:36
4Chan Website Back Online After Days of Sustained DDoS Attack Web Hosting News 2011-11-16 15:44:05
1.3 Million User IDs and Passwords Stolen in Washington Post Jobs Site Hack Web Hosting News 2011-07-07 14:41:28


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?