Re: [PHP] mysql query/$post problem
PHP Mailer wrote: Mark skrev: [snip] $query = "INSERT INTO users AVATARS WHERE id =$user_id '','$avname')"; mysql_query($query);s [snip] I am trying to insert the value of $avname into the users table, into the avatar field. I think what you are trying to do is coordinated a bit wrong, perhaps http://www.w3schools.com/sql/sql_insert.asp could be of some help for you to achieve this in the future. Taking a look at your query, i do see what you are trying to do, but the structure is wrong. $query = "INSERT INTO users (avatars) VALUES ('$avname')WHERE id ='$user_id')"; Also - it looks like an UPDATE might be more suitable for what you want, given that you've got a WHERE clause tacked on the end. Google for a good SQL tutorial; the PHP mailing list is not the place to learn SQL :) Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql query/$post problem
Mark skrev: I havnt even tried this query but i know its wrong can anyone help! *** ** I am trying to insert the value of $avname into the users table, into the avatar field. Hello Mark, I think what you are trying to do is coordinated a bit wrong, perhaps http://www.w3schools.com/sql/sql_insert.asp could be of some help for you to achieve this in the future. Taking a look at your query, i do see what you are trying to do, but the structure is wrong. $query = "INSERT INTO users (avatars) VALUES ('$avname')WHERE id ='$user_id')"; As Nicolas said, it is important that you understand your abilities to debug these queries by outputting them through simple commands such as echo or even the php-mysql function mysql_error(); give these a try Let us know how it works out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql query/$post problem
On 3/27/06, Mark <[EMAIL PROTECTED]> wrote: > I havnt even tried this query but i know its wrong can anyone help! > > > *** > include("header.php"); > include("connect.php"); > > $comp_id = $_SESSION['comp_id']; > $user_id = $_SESSION['user_id']; > > // Grab variables and insert into database > > $avname = $_POST['avname']; > > > $query = "INSERT INTO users AVATARS WHERE id =$user_id '','$avname')"; The format for insert queries is: insert into table(field1, field2) values ('value1', 'value2') or insert into table set field1=value2, field2=value2 etc. What exactly is the tablename? Also you don't need the ) on the end: $query = "INSERT INTO tablename SET id =$user_id '','$avname'"; -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql query/$post problem
Mark a écrit : I havnt even tried this query but i know its wrong can anyone help! *** don't you need a session_start() somewhere ? (or it's in the header.php or connect.php perhaps ?) $comp_id = $_SESSION['comp_id']; $user_id = $_SESSION['user_id']; // Grab variables and insert into database $avname = $_POST['avname']; $query = "INSERT INTO users AVATARS WHERE id =$user_id '','$avname')"; mysql_query($query);s mysql_close(); include("footer.html"); ?> ** I am trying to insert the value of $avname into the users table, into the avatar field. could you tell us a bit more about what's in the $avname ? try an echo $query and run your query with an sql client to check if the database accepts your request. N F -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql query/$post problem
I havnt even tried this query but i know its wrong can anyone help! *** ** I am trying to insert the value of $avname into the users table, into the avatar field. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php