nats0128
nats0128

Reputation: 509

finding wrong data that is non-existent

I am creating a website for a church and in the events section of the code i have this

$page_contents = mysql_query("SELECT * FROM events WHERE id = '$page_content'");
$contents = mysql_fetch_array($page_contents)or die (mysql_error());    

echo "<Script>alert(".$contents['date'].")</script>";

I have 3 entries in the database and the dates are 0000-00-00, 2013-06-14 & 2013-06-19

The $page_content is the $_GET page id this comes through as events/$1/ and changes through .htacess to events.php?page=$1

when date 2013-06-14 is called the above echo script gives out 1993 and when date 2013-06-19 is called i get 1988

I have none of these years in my database or anything representing these in my code ? this has completely baffled me ????

Upvotes: 2

Views: 77

Answers (1)

deceze
deceze

Reputation: 522024

Your output is not a string since you're missing the quotes in the Javascript you're outputting. It actually looks like this:

alert(2013-06-14)

Yeah, those are numbers, which are being subtracted...

Upvotes: 6

Related Questions