Jump to content

Having code problem inserting into a query


Agent12

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.