why do this code bellow give me this error ? <?php require_once("global.php"); $sql = "SELECT id FROM users ORDER BY today DESC LIMIT 1"; $result = mysql_fetch_array($sql); $update_user = mysql_query("update users set featured = featured + 1 where userid = " . $result["id"] . " limit 1"); ?> PHP:
You are missing a mysql_query: $sql = "SELECT id FROM users ORDER BY today DESC LIMIT 1"; mysql_query($sql); $result = mysql_fetch_array($sql); PHP:
ok, so now it looks like this and still errors me :/ <?php require_once("global.php"); $sql = "SELECT id FROM users ORDER BY today DESC LIMIT 1"; mysql_query($sql); $result = mysql_fetch_array($sql); $update_user = mysql_query("update users set featured = featured + 1 where userid = " . $result["id"] . " limit 1"); ?> PHP:
<?php require_once("global.php"); $sql = mysql_query("SELECT id FROM users ORDER BY today DESC LIMIT 1"); $result = mysql_fetch_array($sql); $update_user = mysql_query("update users set featured = featured + 1 where userid = " . $result["id"] . " limit 1"); ?> PHP:
still get the error :/ Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /test.php on line 5
there must be something wrong with your query then. <?php require_once("global.php"); $sql = mysql_query("SELECT id FROM users ORDER BY today DESC LIMIT 1") or die (mysql_error()); $result = mysql_fetch_array($sql); $update_user = mysql_query("update users set featured = featured + 1 where userid = " . $result["id"] . " limit 1"); ?> PHP: That'll tell you the mysql error.
aw.... i had spelled on of the collumns wrong >.< i should learn to read... anyhow, thank you all for the help!