Solved

PHP sql data selection and compare

Posted on 2010-08-23
3
189 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

867 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

15 Experts available now in Live!

Get 1:1 Help Now