Jump to content

Recommended Posts

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' ");



 }

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.