aebstract Posted March 13, 2007 Share Posted March 13, 2007 It's kinda weird, and confusing me. I have tryed a few methods. I am uploading two files, and then all I want to do is add one line to the database. I actually don't need any information added. There is only one column, called id.. it is set to auto increment, so as long as I can add one line to the db then it should just be the next number in line. (which is what I want) Below is my code, maybe someone can tell me how I can get it to just add another line on to my db. <html> <head> <link href="stylesheet.css" rel="stylesheet" type=text/css title=default /> </head> <body> <?php mysql_connect("localhost","hmg","hillpass"); mysql_select_db("hmg"); $result = mysql_query("SELECT * FROM mailers ORDER BY id ASC"); $rows = mysql_num_rows($result); $rows2 = $rows + 1; if (isset($_POST['submit'])) { if (move_uploaded_file($_FILES['thefile']['tmp_name'], $_SERVER['DOCUMENT_ROOT']. "/mailers/$rows2.jpg" )) { } if (move_uploaded_file($_FILES['thefile2']['tmp_name'], $_SERVER['DOCUMENT_ROOT']. "/mailers/big/$rows2.jpg" )) { } $results = MYSQL_QUERY("INSERT INTO mailers (id)". "VALUES (0)"); } ?> <div id="uploadform"> <?php echo "There are currently $rows mailers."; ?> <br /><br /><br /> <form action="test.php" enctype="multipart/form-data" method="post" > Thumbnail Image:<br /> <input type="file" name="thefile" class="upform" /><br /><br /> Large Image:<br /> <input type="file" name="thefile2" class="upform" /><br /><br /> <input name="submit" type="submit" value="add mailer" class="upform" /> </form> </div> </body> </html> Thanks in advance Link to comment https://forums.phpfreaks.com/topic/42535-solved-line-wont-add-in-database/ Share on other sites More sharing options...
interpim Posted March 13, 2007 Share Posted March 13, 2007 why are you assigning data to an auto incrementing field? Link to comment https://forums.phpfreaks.com/topic/42535-solved-line-wont-add-in-database/#findComment-206368 Share on other sites More sharing options...
only one Posted March 13, 2007 Share Posted March 13, 2007 try this: $query = "INSERT INTO mailers (id) VALUES (0)"; mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/42535-solved-line-wont-add-in-database/#findComment-206369 Share on other sites More sharing options...
Vikas Jayna Posted March 13, 2007 Share Posted March 13, 2007 Try this: $query = "INSERT INTO mailers (id) VALUES (null)"; mysql_query($query); The auto_increment field will automatically be assigned the next possible value Link to comment https://forums.phpfreaks.com/topic/42535-solved-line-wont-add-in-database/#findComment-206374 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Author Share Posted March 13, 2007 Thanks guys, I think both Vikas Jayna and only one's answers were both correct. I had actually tryed what only one said, but I had my form pointing to the wrong page (glad I noticed that). Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/42535-solved-line-wont-add-in-database/#findComment-206378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.