473,794 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

11 line random quote system

<?php

//Variables
//Quotes
$quote[0] = "'If at first you don't succeed; call it version 1.0' -
T-Shirt";
$quote[1] = "Microsoft: 'You`ve got questions. We've got dancing
paperclips.' - Unknown";
$quote[2] = "I would love to change the world, but they won't give
me the source code!' - Unknown";
//Random Number
$rndNum = rand(1,3);
//Pring Random Quote
echo $quote[rndNum];
?>
Why does this not do anything!? Please help asap!

-vas

Jul 22 '06 #1
4 1529
On 22 Jul 2006 13:11:18 -0700, "or*****@gmail. com" <or*****@gmail. comwrote:
> echo $quote[rndNum];

Why does this not do anything!? Please help asap!
Look at http://uk2.php.net/error_reporting

Turn up your error reporting level to maximum. PHP will then tell you why. The
code above will raise a warning message.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 22 '06 #2

or*****@gmail.c om wrote:
<?php

//Variables
//Quotes
$quote[0] = "'If at first you don't succeed; call it version 1.0' -
T-Shirt";
$quote[1] = "Microsoft: 'You`ve got questions. We've got dancing
paperclips.' - Unknown";
$quote[2] = "I would love to change the world, but they won't give
me the source code!' - Unknown";
//Random Number
$rndNum = rand(1,3);
//Pring Random Quote
echo $quote[rndNum];
?>
Why does this not do anything!? Please help asap!

-vas
This will produce a random quote from an array...

<?php
//Where $quote is a string array
echo $quote[array_rand($quo te)];
?>

Jul 23 '06 #3

or*****@gmail.c om wrote:
<?php

//Variables
//Quotes
$quote[0] = "'If at first you don't succeed; call it version 1.0' -
T-Shirt";
$quote[1] = "Microsoft: 'You`ve got questions. We've got dancing
paperclips.' - Unknown";
$quote[2] = "I would love to change the world, but they won't give
me the source code!' - Unknown";
//Random Number
$rndNum = rand(1,3);
//Pring Random Quote
echo $quote[rndNum];
?>
Why does this not do anything!? Please help asap!

-vas
Also, here is what was wrong with your code...

<?php
//Variables
//Quotes
$quote[0] = "'If at first you don't succeed; call it
version 1.0' - T-Shirt";
$quote[1] = "Microsoft: 'You`ve got questions. We've
got dancing paperclips.' - Unknown";
$quote[2] = "I would love to change the world, but they
won't give me the source code!' - Unknown";

//Random Number
$rndNum = rand(0,2); //The range should be from 0, 2
not 1, 3
//Pring Random Quote
echo $quote[$rndNum]; //Left the $ off rndNum

?>

Jul 23 '06 #4
Noodle wrote:
or*****@gmail.c om wrote:
><?php

//Variables
//Quotes
$quote[0] = "'If at first you don't succeed; call it version 1.0' -
T-Shirt";
$quote[1] = "Microsoft: 'You`ve got questions. We've got dancing
paperclips.' - Unknown";
$quote[2] = "I would love to change the world, but they won't give
me the source code!' - Unknown";
//Random Number
$rndNum = rand(1,3);
//Pring Random Quote
echo $quote[rndNum];
?>
Why does this not do anything!? Please help asap!

-vas

This will produce a random quote from an array...

<?php
//Where $quote is a string array
echo $quote[array_rand($quo te)];
?>
Wrong idea. Not integers.

Try shuffle($quotes );

echo $quote[0];

Louise

Jul 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2757
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
1
5211
by: ssims | last post by:
I've got this code for a random GDI+ chart generator, and the demo works, but when I try to run it on my local machine I get a compiler error: Compiler Error Message: CS0117: 'Random' does not contain a definition for 'Next' Here's the code: using System; using System.Collections; using System.ComponentModel; using System.Data;
11
3612
by: Kevin Williamson | last post by:
Hi, I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares. The problem I have is that of the ten winners one week the same share number was drawn the next week and an adjacent share number the following week (that just happened to be owned by the same member) The program is now being looked at suspisciously.
8
3915
by: Daniel | last post by:
Hey guys Using Random(), how random is it, is it possible to be predicted? I have a requirement for a very good random number generator. I was doing something such as: Random randomSeed = new Random((int)_seedTimer.ElapsedTicks); _random = new Random(randomSeed.Next(0,99999999)); return random.Next(min, max);
12
8733
by: Juha Nieminen | last post by:
I'm trying to use a random number generator and rand() is just not up to the task (RAND_MAX is way too small). I searched in the help system and found the System::Random class which seems to be just perfect. However, for some odd reason the help files simply refuse to tell what should be #included in order to use the class. I can't find this info anywhere! Even the example program given in the help lacks this information (and thus of...
41
2379
by: Zytan | last post by:
Anyone do any tests on it? I would assume it has improved since C's rand(), but who knows. For some reason, and it could just be coincidence, I seem to see patterns. But even a crappy rand() function should be good enough to avoid that, so i may be seeing things. Zytan
8
7559
by: Anil Gupte | last post by:
I had someone write a random number generator in C# (I am more of a VB programmer) and they came up with the following: public string GetRand(int count) { string number = ""; for (int i=0; i<count; i++) { Random Rnd = new Random(); number = number+Convert.ToString(Rnd.Next(0,9));
24
7236
by: pereges | last post by:
I need to generate two uniform random numbers between 0 and 1 in C ? How to do it ? I looked into rand function where you need to #define RAND_MAX as 1 but will this rand function give me uniformly distributed and unique numbers ?
17
6732
by: almurph | last post by:
Hi, Hope you can help me with this one. I am trying to create random number between 0 and 1 inclusive of cryptographiuc quality. The problems is though - I don't know how! Here is what I have so far and I would greatly appreciate any comments/suggestions/code-samples that you may like to share. Thank you. Al
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.