solisis Posted April 29, 2006 Share Posted April 29, 2006 Obviously I'm new to this so please bear with me...My UPDATE query works fine when updating a database column with an int value to it but when I use the same exact code to update something with, say, varchar or text it doesn't work.I can think of no other issue besides the possibility that I have to prepare the text for insertion, though this doesn't make much sense because if I use INSERT it will do its job fine. Perhaps you can help me understand why UPDATE isn't accepting the query.Here's the basics of the code... $query = "UPDATE ".$table." SET description = ".$val." WHERE id = ".$g.""; mysql_db_query($database, $query) or die("Failed Query"); The necessary connection code and variable values are in tact because if I swap "$query =" with "print" it prints out the correct code as it should be.If you have any questions or comments they would be appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/8693-update-not-working-why/ Share on other sites More sharing options...
.josh Posted April 29, 2006 Share Posted April 29, 2006 so what type of error msg does it give? Link to comment https://forums.phpfreaks.com/topic/8693-update-not-working-why/#findComment-31905 Share on other sites More sharing options...
kenrbnsn Posted April 29, 2006 Share Posted April 29, 2006 Strings need to be delimited by single quotes in the query:[code]<?php $query = "UPDATE ".$table." SET description = '".$val."' WHERE id = ".$g."";mysql_db_query($database, $query) or die("Failed Query: $query<br>".mysql_error());?.[/code]Ken Link to comment https://forums.phpfreaks.com/topic/8693-update-not-working-why/#findComment-31918 Share on other sites More sharing options...
solisis Posted April 30, 2006 Author Share Posted April 30, 2006 Thank you very much kenrbnsn. I wasn't aware that I'd have to do that.It works perfectly now.Crayon Violent- I wasn't getting an error because all i told it to do was print failed query if it failed. Link to comment https://forums.phpfreaks.com/topic/8693-update-not-working-why/#findComment-32103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.