ballhogjoni Posted July 3, 2007 Share Posted July 3, 2007 I am wondering why this does not write to my db? Can someone help me out a little? Thanks in advance $index_page_title=$_GET['index_page_title']; if (!empty($index_page_title)) { include('config.php'); if (mysql_query('SELECT * FROM title WHERE ID==1') == TRUE) { mysql_query('UPDATE title SET Title = $index_page_title'); } else { mysql_query("INSERT INTO title (Title) VALUES ('$index_page_title')"); } Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/ Share on other sites More sharing options...
teng84 Posted July 3, 2007 Share Posted July 3, 2007 is ther any error? Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/#findComment-288414 Share on other sites More sharing options...
ballhogjoni Posted July 3, 2007 Author Share Posted July 3, 2007 No, not that I can tell Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/#findComment-288415 Share on other sites More sharing options...
teng84 Posted July 3, 2007 Share Posted July 3, 2007 whats the prob the insert or update Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/#findComment-288417 Share on other sites More sharing options...
ballhogjoni Posted July 3, 2007 Author Share Posted July 3, 2007 It is supposed to check to see if there is a record in the table and if there is, update it and if there is not add it. It is not doing either from what I can see. Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/#findComment-288441 Share on other sites More sharing options...
teng84 Posted July 3, 2007 Share Posted July 3, 2007 try this if (mysql_query('SELECT * FROM title WHERE ID=1')) { // you have == on your code i dont think it proper to use == in sql and also check if this is being set $index_page_title Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/#findComment-288445 Share on other sites More sharing options...
ballhogjoni Posted July 3, 2007 Author Share Posted July 3, 2007 yea I know that the variable is being set due to the fact that I am usinf the GET method in my form but I will try the = instead of == Link to comment https://forums.phpfreaks.com/topic/58149-mysql-syntax-input-for-the-database/#findComment-288450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.