Andy713 Posted September 21, 2007 Share Posted September 21, 2007 Hi Guys, I have a problem and I've worked through the problem for almost a day and a half now and I can't get it to work. -The function is to add a team member to a roster table -The function has been working for over a week and a half now, and stopped working recently without making any changes to the code. -I have all mysql connnections closed after I've used them so that the database isn't overloaded with different connections. -I have several other functions structured almost exactly the same and they work fine. -I can still edit rows in the table, but I can't insert a new row into the table -The only change that I've made to anything relative to the function is an upload image script in the edit function of the roster, and they use seperate databases -Also I've used the same exact code for an upload sponsor logo for a seperate edit sponsor function and it is working fine, I can still add, edit, and delete sponsors. -The Form variables do get transferred to the php execution script and I can display them on the page that actually executes the script. I will add more details as I remember them, hopefully you can see something I don't. Here is my Form and the script that inserts the form variables into the table: <form method='post' action='memberadded.php'> <TABLE border='0'> <TR> <TD><span class='form-font'>First Name:</span></TD> <TD><INPUT class='input' TYPE='TEXT' NAME='first' size=60></TD> </TR> <TR> <TD><span class='form-font'>Last Name:</span></TD> <TD><INPUT class='input' TYPE='TEXT' NAME='last' size=60></TD> </TR><br> <TR> <TD><span class='form-font'>Position:</span></TD> <TD><INPUT class='input' TYPE='TEXT' NAME='position' size=60></TD> </TR><br> <TR> <TR> <TD><span class='form-font'>Marker:</span></TD> <TD><INPUT class='input' TYPE='TEXT' NAME='marker' size=60></TD> </TR><br> <TR> <TD><span class='form-font'>Years Playing:</span></TD> <TD><INPUT class='input' TYPE='TEXT' NAME='years' size=60></TD> </TR><br> <TR> <TD><span class='form-font'>Past Teams:</span></TD> <TD><INPUT class='input' TYPE='TEXT' NAME='pastteams' size=60></TD> </TR><br> <TR> <TD colspan='2'><center><br /> <INPUT class='submit' TYPE='submit' name='submit' value='submit'></center></TD> </TR> </TABLE> </form> Method Script: <? //initilize PHP if($_POST['submit']) //If submit is hit { //then connect as user //change user and password to your mySQL name and password $link = mysql_connect("localhost","USERNAME","PASSWORD"); //select which database you want to edit mysql_select_db("sundayso_panel"); //convert all the posts to variables: $first = $_POST['first']; $last = $_POST['last']; $position = $_POST['position']; $marker = $_POST['marker']; $years = $_POST['years']; $pastteams = $_POST['pastteams']; $result=MYSQL_QUERY("INSERT INTO roster (id,first,last,position,marker,years,pastteams)". "VALUES ('NULL', '$first','$last','$position','$marker',$years,'$pastteams')"); //confirm print("<h1>Member Added</h1><br /> <a href='addmember.php'>Add another Member</a> <br />"); } mysql_close($link); ?> Hopefully you guys will see something I don't and we can get this fixed, the whole project is almost 90% done and this is one of the only things standing in my way Quote Link to comment Share on other sites More sharing options...
anocweb Posted September 21, 2007 Share Posted September 21, 2007 i actually posted a similar problem no answer yet though http://www.phpfreaks.com/forums/index.php/topic,160253.0.html Quote Link to comment Share on other sites More sharing options...
Andy713 Posted September 21, 2007 Author Share Posted September 21, 2007 I also manually inserted a row into the table and it worked fine, so the ability to insert a table is possible. I really am stumped on what it could be Quote Link to comment Share on other sites More sharing options...
Andy713 Posted September 22, 2007 Author Share Posted September 22, 2007 I wanted to edit my original post but I can't find the button anyway here is some of the required information: MySQL client version: 4.1.10 I received no mysql errors and I don't know how to test a query, but I think its possible. Here is my mySQL query code $result=MYSQL_QUERY("INSERT INTO roster (id,first,last,position,marker,years,pastteams)". "VALUES ('NULL', '$first','$last','$position','$marker',$years,'$pastteams')"); I want it to add a row to the roster table and it won't do that, other similiar functions are doing it right and are coded almost exactly the same. Quote Link to comment Share on other sites More sharing options...
Andy713 Posted September 22, 2007 Author Share Posted September 22, 2007 Okay so I've fixed the problem, but its not exactly solved. I just copied the query from the add sponsor function and replaced the roster code with this: Can someone spot the difference in the code: original roster query (non-working one): $result=MYSQL_QUERY("INSERT INTO roster (id,first,last,position,marker,years,pastteams)". "VALUES ('NULL', '$first','$last','$position','$marker',$years,'$pastteams')"); New Roster Query (works...for now) $result=MYSQL_QUERY("INSERT INTO roster (id,first,last,position,marker,years,pastteams)". "VALUES ('NULL', '$first','$last','$position','$marker','$years','$pastteams')"); I can't see any differences...maybe you can. one works, one doesn't. This is extremely frustrating. Also Mods, is there any point for this forum, It seems like everyone just posts their problem in PHP help no matter what it has to do with... Quote Link to comment Share on other sites More sharing options...
effigy Posted September 22, 2007 Share Posted September 22, 2007 You should be error checking. Try mysql_query(...) or die(mysql_error()); Also Mods, is there any point for this forum, It seems like everyone just posts their problem in PHP help no matter what it has to do with... Yes, it's for MySQL questions. All 5,667 of them, currently. Many MySQL questions are actually PHP questions, because PHP is accessing MySQL. Quote Link to comment Share on other sites More sharing options...
Andy713 Posted September 22, 2007 Author Share Posted September 22, 2007 I am having the exact same problem when I try to add a gallery: MySQL client version: 4.1.10 here is the mysql code: $result=MYSQL_QUERY("INSERT INTO gallery (id,name,desc, url)". "VALUES ('NULL', '$name', '$desc','$url')") or die(mysql_error()); here is the mysql error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, url)VALUES ('NULL', 'Miami', 'This is our thing about miami','http://www.a' at line 1 I don't really see any problems with the syntax, maybe you guys can see something I can't. Quote Link to comment Share on other sites More sharing options...
effigy Posted September 23, 2007 Share Posted September 23, 2007 desc is a reserved word in MySQL. Either change it or backtick it: `desc` Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.