sstangle73 Posted August 13, 2007 Share Posted August 13, 2007 function addNew9sch($ID, $Type, $HR, $Period1, $Period2, $Period3, $Period4, $Period5, $Period6, $Period7, $Period8, $Period9){ global $conn; $q2 = "INSERT INTO schedule VALUES ('$ID', '$Type', '$HR', '$Period 1', '$Period 2', '$Period 3', '$Period 4', '$Period 5', '$Period 6', '$Period 7', '$Period 9')"; return mysql_query($q2,$conn); } $type = '9Per'; $hr = $_POST['hr']; $per1 = $_POST['per1']; $per2 = $_POST['per2']; $per3 = $_POST['per3']; $per4 = $_POST['per4']; $per5 = $_POST['per5']; $per6 = $_POST['per6']; $per7 = $_POST['per7']; $per8 = $_POST['per8']; $per9 = $_POST['per9']; $_SESSION['regresult'] = addNew9sch($ID, $type, $hr, $per1, $per2, $per3, $per4, $per5, $per6, $per7, $per8, $per9); if($_SESSION['regresult']){ echo "Success"; } else { echo "Failed"; } results with failed cant figure it out Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/ Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 Firstly... where do you define $ID, $type and $hr. Secondly.... have you tried any debugging? eg; $result = mysql_query($q2,$conn) or die(mysql_error()); return $result; Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321977 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 Just spotted. What with the spaces in variable names? '$Period 1', '$Period 2', '$Period 3', Should be.... '$Period1', '$Period2', '$Period3', Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321978 Share on other sites More sharing options...
Fadion Posted August 13, 2007 Share Posted August 13, 2007 Also is $conn properly set and do u have session_start()? Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321980 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 yeah thats what i thought it failed with no space. i put the space in there after the original code to see if i could get it to work $type = '9Per'; $hr = $_POST['hr']; was right in there dont know why u missed it and the ID was defined earlier in the page when i run a query from the table users ill try the debug now yes and yes Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321982 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 So what is the outcome of.... $result = mysql_query($q2,$conn) or die(mysql_error()); ? Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321983 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 i had return mysql_query($q2,$conn); and ran with both in there still no go what is it supposed to say:? Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321985 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 It will tell you what your error is. Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321987 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 im sorry im a nOOb do should i put it in the else? or where Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321989 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 Change your function to the following then post your output. function addNew9sch($ID, $Type, $HR, $Period1, $Period2, $Period3, $Period4, $Period5, $Period6, $Period7, $Period8, $Period9){ global $conn; $q2 = "INSERT INTO schedule VALUES ('$ID', '$Type', '$HR', '$Period1', '$Period2', '$Period3', '$Period4', '$Period5', '$Period6', '$Period7', '$Period9')"; if ($result(mysql_query($q2,$conn)) { return $result; } else { die(mysql_error() . "<br />" . $q2); } } Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321991 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 parse error: parse error, unexpected '{' in /homepages/27/d193007783/htdocs/stangle/editschedule.php on line 41 41 is if ($result(mysql_query($q2,$conn)) { Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321995 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 oh not enought )s nvm Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321997 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 Fatal error: Call to undefined function: () in /homepages/27/d193007783/htdocs/stangle/editschedule.php on line 41 Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-321999 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 Sorry... my fault, your function ought look like.... function addNew9sch($ID, $Type, $HR, $Period1, $Period2, $Period3, $Period4, $Period5, $Period6, $Period7, $Period8, $Period9){ global $conn; $q2 = "INSERT INTO schedule VALUES ('$ID', '$Type', '$HR', '$Period1', '$Period2', '$Period3', '$Period4', '$Period5', '$Period6', '$Period7', '$Period9')"; if ($result = mysql_query($q2,$conn)) { return $result; } else { die(mysql_error() . "<br />" . $q2); } } Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322001 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 Column count doesn't match value count at row 1 INSERT INTO schedule VALUES ('1', '9Per', 'HR', '1', '2', '3', '4', '5', '6', '7', '9') Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322003 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 Ok, that error means you are either supplying too many or not enough VALUES. This is why you should always specify your field names explicitly. eg; INSERT INTO (fld1,fld2,fld3) VALUES ('val1','val2','val3'); Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322006 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 wth weres 8 that took me a while to figure out 8 was missing lol stupid mind tricks [no im not retarted i wasnt tring that whole tim e ] now on to how to fix it! TO THE CODE! Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322007 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 lol you forgot 8 in the function you gave me Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322009 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 lol you forgot 8 in the function you gave me All I did was copy/paste and modify. Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322010 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 yeah just cought that? how do i forget to count to 10? Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322011 Share on other sites More sharing options...
sstangle73 Posted August 13, 2007 Author Share Posted August 13, 2007 Success rofl thanks thorpe Quote Link to comment https://forums.phpfreaks.com/topic/64586-solved-mysql-entry/#findComment-322012 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.