alexander007 Posted September 30, 2007 Share Posted September 30, 2007 Im having an error with this and cant find what its the correct syntax... <?php $nombre = $_SESSION['nombre']; $visited = $_SESSION['visited']; echo $nombre, $visited; include"config.php"; $tbl_name="visitantes"; mysql_query("INSERT INTO ".$tbl_name." (visited) VALUES('','".$visited."') WHERE nombre = $nombre ") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/ Share on other sites More sharing options...
shocker-z Posted September 30, 2007 Share Posted September 30, 2007 you putting 2 values but only specified 1 column mysql_query("INSERT INTO ".$tbl_name." (visited) VALUES('".$visited."') WHERE nombre = $nombre ") or die(mysql_error()); try that I removed '', Liam Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358648 Share on other sites More sharing options...
teng84 Posted September 30, 2007 Share Posted September 30, 2007 i dont know if insert needs a where clause ? i hanvent seen anything like that where is not for insert ! Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358649 Share on other sites More sharing options...
AndyB Posted September 30, 2007 Share Posted September 30, 2007 INSERT adds a record, therefore needs no WHERE; UPDATE updates a record and therefore needs a WHERE. Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358652 Share on other sites More sharing options...
shocker-z Posted September 30, 2007 Share Posted September 30, 2007 ohh yeah i missed the obvious but saw the less obvious can tell it's sunday Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358655 Share on other sites More sharing options...
alexander007 Posted September 30, 2007 Author Share Posted September 30, 2007 Thanks for your help... But Im still getting the error Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358656 Share on other sites More sharing options...
alexander007 Posted September 30, 2007 Author Share Posted September 30, 2007 So to do that I need to use UPDATE? Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358658 Share on other sites More sharing options...
shocker-z Posted September 30, 2007 Share Posted September 30, 2007 Try this mysql_query("UPDATE ".$tbl_name." SET visited = '".$visited."' WHERE nombre = '$nombre'") or die(mysql_error()); Is that better? Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358661 Share on other sites More sharing options...
AndyB Posted September 30, 2007 Share Posted September 30, 2007 So to do that I need to use UPDATE? Use UPDATE to change an existing record Use INSERT to add a new record. Which you want depends on what you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358664 Share on other sites More sharing options...
alexander007 Posted September 30, 2007 Author Share Posted September 30, 2007 That do te trick!!! Thanks to all!!! Quote Link to comment https://forums.phpfreaks.com/topic/71296-solved-phpmysqlwhere-syntax/#findComment-358669 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.