Just to point out, when you try to echo $result
you are only echoing the resource since that is what mysql_query
returns.
If you want to echo the column, try:
while($row = mysql_fetch_assoc($result)) {
echo $row['date'];
}
Or you could use mysql_result
which return the return value into a string.
$query = "SELECT MAX(date) FROM Records WHERE ips='$currentip'";
$date = mysql_result($result, 0);
echo $date;
Either should work, it hasn't been tested or compiled.
In regards to your updated code:
<?php
$db = mysql_connect("localhost", "123", "123");
mysql_select_db("123");
$currentip='123.456.789';
$query = "SELECT MAX(date) FROM Records WHERE ips='$currentip'";
$result = mysql_query($query); // <--you forgot this line.
$date = mysql_result($result, 0); // <--now $result has a valid resource.
echo $date;
?>
I would also strongly suggest that since you are a new PHP programmer, get into the habit of incorporating some form of error-handling/checking, such as
$db = mysql_connect("localhost", "123", "123");
if (!$db) {
die('Could not connect: ' . mysql_error());
}
...
$result = mysql_query($query);
if (!$result) {
die('Could not perform query: ' . mysql_error());
}
Performing error-checks from the start of your programming experience is really good practice and will better suit you for the long-run.