Solved

PHP sql data selection and compare

Posted on 2010-08-23
3
188 Views
Last Modified: 2013-12-13
// I have problem. it does not take tha date and assign it to the  $date_comingfrom_database
what should I do?

$query = "SELECT Email,Date FROM Mytable where Email='$visitoremail'";
$sql=mysql_query($query);
$result = mysql_fetch_array($query); // I have error message Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /
// I have problem here it does not take tha date and assign it to the  $date_comingfrom_database

$date_comingfrom_database = $result['Date'];
$databaseemail =$result['Email'];

$todaysdate = date('Y-m-d H:i:s');

if ( ( strtotime('Y-m-d H:i:s') - strtotime($date_comingfrom_database) >= 50 ) && ($databaseemail = $visitormail))
{
echo "record exist."  . $date_comingfrom_database . " ".$databaseemail. " ".$visitormail    ;
}
else
{
echo "record not exist." . $date_comingfrom_database . " ".$databaseemail. " ".$visitormail    ; // it only writes record not exist. and $visitormail here
}

I'll be back in 25 minutes..
0
Comment
Question by:Braveheartli
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Snarfles earned 500 total points
ID: 33499099
change

$result = mysql_fetch_array($query); // I have error message Warning: mysql_fetch_array(): supplied argument

to

$result = mysql_fetch_array($sql); // I have error message Warning: mysql_fetch_array(): supplied argument
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 33499226
you are great,
thank you
0
 
LVL 9

Expert Comment

by:Snarfles
ID: 33499259
You're welcome :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now