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
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

 

Link to comment
Share on other sites

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.