Solved

PHP sql data selection and compare

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 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