Agent12 Posted August 4, 2007 Share Posted August 4, 2007 Having trouble updating or inserting into a field in the db. Other actions in other pages seems to work correctly. What is my problem here? 10x helpers echo "<form method=\"post\" action=\"index.php\">" ."<b>Text here:</b><br><textarea name=\"content\" value=\"$content\" cols=\"50\" rows=\"200\"></textarea>" ."<input type=\"hidden\" name=\"case\" value=\"update\">" ."<center><input type='submit' value='send'></center>" ."</form>"; switch($case) { case "update": update_news($content); } function update_news($content) { global $db $db->sql_query("UPDATE new_content SET stext = '$content' WHERE t_id = '1' "); } Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/ Share on other sites More sharing options...
pyrodude Posted August 4, 2007 Share Posted August 4, 2007 I'm new to MySQL, but the update query looks right to me. unrelated to your issue, however, I find the code to be a lot cleaner if you exit php to display large amounts of html (your form code). Also, your issue appears to be with updating not inserting into a database Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/#findComment-315603 Share on other sites More sharing options...
Agent12 Posted August 4, 2007 Author Share Posted August 4, 2007 it doesn't matter if I am trying to update, delete, insert or dump. It just doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/#findComment-315610 Share on other sites More sharing options...
pyrodude Posted August 4, 2007 Share Posted August 4, 2007 I could be wrong, but try changing sql_query() to mysql_query() I couldn't find documentation of the sql_query function (unless it's a user-defined function) Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/#findComment-315613 Share on other sites More sharing options...
Agent12 Posted August 4, 2007 Author Share Posted August 4, 2007 it is a user defined function but I have already used it in other places, and it worked fine. anything else? Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/#findComment-315615 Share on other sites More sharing options...
pnj Posted August 4, 2007 Share Posted August 4, 2007 I don't see anything at a glance, but you could try storing the query in a string variable, printing the string, and then popping it into the MySQL command line, which would tell you pretty quickly if your query is wrong or if you're not getting the $content value set properly. If its a textarea, you might want to use mysql_real_escape_string ($content) as well. -pnj Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/#findComment-315626 Share on other sites More sharing options...
BlueSkyIS Posted August 4, 2007 Share Posted August 4, 2007 Any error messages?? -BSIS Quote Link to comment https://forums.phpfreaks.com/topic/63329-having-code-problem-inserting-into-a-query/#findComment-315710 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.