random number generator

Started on the old forum in July 2012 · view the original in the archive · old links redirect here

3 replies · 586 views · started 14 years ago · 1 min read

3 participants
nclemale36 Lead · 537 posts #1

hi .i am looking for some code to generate a random number for users. this number will then be inserted to there profile . its the actual random number generating thats giving me the head ache . seen so many different codes on how to do it its confused me .

<?php
$random = rand (1, 500)  
echo" $random";
?>

this is the simplest of the lot i have found but i cant get it to show the number on the page . am getting error on line 3.

any help appreciated.

nclemale36 Lead · 537 posts #3

lol mate you beat me to it.

thats the exact same code gum .? but the one below i just done works. cheers.

<?php
$random = mt_rand(0, 500);  
echo $random
?>
Ghost Senior · 366 posts #4

nclemale36 wrote: thats the exact same code gum .?

is the same code. gums just fixed the syntax error is all, whenever an error appears and tells you the line number of that error. you can be almost guaranteed that the error is on the line/lines above the line it says it has an error on. 99% of the time lol.

for example. you said line 3 was popping off errors. your syntax problem was on line 2 missing a ; at the end of the line.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close