Jump to content

[SOLVED] Adding something to the db


xoligy

Recommended Posts

Ive been trying to add some info to the db but have been failing misrably this is probably because ive been concentrating with the php rather than the mysql side of things and with no net at home and no books in the libery on php things are going really slow! This is the code ive been trying to use to add to the db:

 

	<?php
                if ($_POST['submit']){
                    
                    $description = stripslashes($_POST['description']);
                    
                    $query = "UPDATE `UserDetails` SET description = '$description' WHERE ID = '$id'";
                    $result = @mysql_query($query);
                }
                ?>
            <TD colspan="2" align="center"><B>Profile Description:</B><br>
            <FORM method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
            <textarea rows="5" cols="10" name="description" maxlength="500"><?$description?></textarea>
            <br /><INPUT name="submit" type="submit" value="Update Profile" />
                <input type="hidden" name="submitted" value="TRUE" />

 

As you can see im trying to add the info to userdetails -> description from the above code i have removed maxlength as thats going to be added to another php file, via a function if i can do it lol Also the connection to the db is in another file with all the other functions

 

Link to comment
https://forums.phpfreaks.com/topic/111643-solved-adding-something-to-the-db/
Share on other sites

one thing I always found helpful would be to comment out the line that commits to the database, and instead do an

echo $query

 

then take what it prints out and run it on your database.  If it succeeds, you know your query is correct. if it fails, it will tell you why

 

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.