genista Posted May 16, 2006 Share Posted May 16, 2006 Hi guys,I am getting the following error off the code below:Parse error: parse error, unexpected $ in blah/blah on line 89.I know this has got to be an open bracket or something like that but I cannot spot it for thelife of me.ANy one got any ideas?:[code]<?phpfunction trimdata($formdata){//Trim any leading or trailing spaces//$formdata=form data arrayforeach ($formdata as $key=> $value){$new_array[$key] = trim($value);}return $new_array;}function check_password_length($formdata, $password, $minlen){//check the password is the correct length//$formdata = form data array//$password = name of password field//$minlen = minimum length of password fieldif (strlen($formdata[$password]) < $minlen)return false;}return true;}function confirm_password($formdata, $password, $password2){//check the two paswords matchif ($formdata[$password1] === $formdata[$password2])return true;else return false;}function check_unique ($formvalue, $mydb, $myhost, $myuser, $mypass, $table, $field){//Check to see if the value still exists in the database//$formvalue = unique value to be checked$error = "";//Connect to the mysql server$mysql = mysql_connect($myhost, $myuser, $mypass);if(!$mysql){$error = "cannot connect to the database host";return($error);}////open the database$mysqldb = mysql_select_db($mydb);if(!mysqldb){{$error = "Cannot open database";return($error);}//Query table to see if $formvalue is unique$myquery = "SELECT * FROM $users where $username = '$formvalue'";$result = mysql_query($myquery);{$error = "Cannot run query";return($error);}//Get number of records found, should be 0 if formvalue is unique$unique = mysql_num_rows($result);if ($unique > 0){$error = $formvalue. "Already in use";return($error);}//Return true if $formvalue is uniquereturn("true");} ?>[/code]Edited by ryanlwh: Added the [code] block Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/ Share on other sites More sharing options...
ryanlwh Posted May 16, 2006 Share Posted May 16, 2006 i spot two errors. there might be more[code]function check_password_length($formdata, $password, $minlen){//check the password is the correct length//$formdata = form data array//$password = name of password field//$minlen = minimum length of password fieldif (strlen($formdata[$password]) < $minlen)return false;}return true;}[/code]missing { after if (or extra } after return false;)[code]////open the database$mysqldb = mysql_select_db($mydb);if(!mysqldb){{$error = "Cannot open database";return($error);}[/code]extra { before $error Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36376 Share on other sites More sharing options...
alpine Posted May 16, 2006 Share Posted May 16, 2006 or replacing } with else[code]function check_password_length($formdata, $password, $minlen){//check the password is the correct length//$formdata = form data array//$password = name of password field//$minlen = minimum length of password fieldif (strlen($formdata[$password]) < $minlen)return false;elsereturn true;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36377 Share on other sites More sharing options...
genista Posted May 16, 2006 Author Share Posted May 16, 2006 Thanks! Changed those, but still the same unfortunatly, any other ideas.Incidentally the line number that is erroring -(89), does not exist in this include file.G Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36379 Share on other sites More sharing options...
alpine Posted May 16, 2006 Share Posted May 16, 2006 i can't find any more, even tested it myself without errors - are you sure it is that file you have the error report on now? Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36385 Share on other sites More sharing options...
genista Posted May 16, 2006 Author Share Posted May 16, 2006 I am testing this through the join form which calls this include file. When I navigate to the join form I get the error for the include file. Surely if it were an error on the join form it would say that, as opposed to showing an error on the include file?G[!--quoteo(post=374431:date=May 16 2006, 04:21 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 16 2006, 04:21 PM) [snapback]374431[/snapback][/div][div class=\'quotemain\'][!--quotec--]i can't find any more, even tested it myself without errors - are you sure it is that file you have the error report on now?[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36401 Share on other sites More sharing options...
dlowery Posted May 16, 2006 Share Posted May 16, 2006 "I ain't no ex-spurt, but..." if the error line is outside the code file chances are that there's a missing brace '{}' or parenthesis '()'. I use a code editor that lets you check this quickly. Put your cursor in front of the first opening brace, hit CTRL-M and it finds the closing brace. No matter how deep or complex and free of charge! And so on down the line. The editor has features like tidy, strip M$Word excesses, and things I haven't explored...it's great! Google "HTML-Kit". There's a free version; look for it. There's probably some others in OSS and for linux. I just haven't looked.Have fun!dlowery Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36436 Share on other sites More sharing options...
ryanlwh Posted May 17, 2006 Share Posted May 17, 2006 you might have some errors in the script that includes it. you might want to post the corrected version of this one too. Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36442 Share on other sites More sharing options...
genista Posted May 17, 2006 Author Share Posted May 17, 2006 Hi guys,I have just tested the include file on its own (whereas before I was running the join form and getting the error) and I get the same error so it must be in the include file...I'll post it again with the changes I made last night:<?phpfunction trimdata ($formdata){//Trim any leading or trailing spaces//$formdata=form data arrayforeach ($formdata as $key=> $value){$new_array[$key] = trim($value);}return $new_array;}function check_password_length($formdata, $password, $minlen){//check the password is the correct length//$formdata = form data array//$password = name of password field//$minlen = minimum length of password fieldif (strlen($formdata[$password]) <$minlen)return false;elsereturn true;}function check_unique ($formvalue, $db, $dbhost, $dbuser, $dbpassword, $table, $field){//Check to see if the value still exists in the database//$formvalue = unique value to be checked$error = "";}function insert_data($formdata){//insert data into the users table//$formdata = form array//set up database connection$error = "";$myhost = "ipaddress";$myuser = "username";$mypass = "password";$mydb = "database name";//data to insert$first_name = $formdata ['first_name']; $last_name = $formdata ['last_name']; $maiden_name = $formdata['maiden_name']; $address_line1 = $formdata ['address_line1']; $address_line2 = $formdata['address_line2'];$town = $formdata['town']; $county = $formdata['county']; $postcode = $formdata['postcode'];$daytime_phone = $formdata['daytime_phone'];$evening_phone = $formdata['evening_phone']; $email_address = $formdata['email_address'];$date_ofbirth = $formdata['date_ofbirth']; $wedding_date = $formdata['wedding_date']; $number_ofguests = $formdata['number_ofguests']; $wedding_venue = $formdata['wedding_venue'];$wedding_area = $formdata['wedding_area'];$username = $formdata['username']; $info = $formdata['info'];//encrypt the password//$password =crypt ($password, "DWMXPHP"); //connect to the database//connect to the server$mysql = mysql_connect($dbhost, $dbuser, $dbpassword);if(!Mysql){$error = "Cannot connect to the database";return($error);{//Open the database$mysqldb = mysql_select_db($db);if (!$mysqldb)$error = "Cannot open Database";return($error);}?> Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36563 Share on other sites More sharing options...
genista Posted May 17, 2006 Author Share Posted May 17, 2006 Am I missing a closing bracket at the end? Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36685 Share on other sites More sharing options...
alpine Posted May 17, 2006 Share Posted May 17, 2006 Hi, you seem to have messed things up a bit again with some missing and som wrong brackets, please follow your first posted code and make the adjustments stated in the following posts and it will work.I advice you to use a php editor that will highlight your syntax as you write, making opening and closing brackets match themselves. I recoment the totally free [a href=\"http://www.mpsoftware.dk/\" target=\"_blank\"]PHP Designer[/a] as a good freehand tool. Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-36700 Share on other sites More sharing options...
genista Posted May 22, 2006 Author Share Posted May 22, 2006 Hi all,Ok so I am really stuck now (and frustrated) this script is now giving me the following error and I have highlighted the line that is causing the error:Parse error: parse error, unexpected T_ARRAY in /home/fhlinux245/h/blah.com/user/Includes/testinclude.php on line 38Thanks,G[code]<?phpfunction trimdata($formdata){ //Trim any leading or trailing spaces //$formdata=form data array foreach ($formdata as $key=> $value) { $new_array[$key] = trim($value); } return $new_array;}function check_password_length($formdata, $password, $minlen){ //check the password is the correct length //$formdata = form data array //$password = name of password field //$minlen = minimum length of password field if (strlen($formdata[$password]) <$minlen) return false; else return true;}function confirm_password($formdata, $password, $password2){ //check the two paswords match if ($formdata[$password1] === $formdata[$password2]) return true; else return false;}//Connect to the mysql server$mysql = mysql_connect($myhost, $myuser, $mypass);[b]if(!$mysql)[/b]{ $error = "cannot connect to the database host"; return($error);}////open the database$mysqldb = mysql_select_db($mydb);if(!mysqldb){ $error = "Cannot open database"; return($error);}//Query table to see if $formvalue is unique$myquery = "SELECT * FROM $users where $username = '$formvalue'";$result = mysql_query($myquery);{ $error = "Cannot run query"; return($error);}//Get number of records found, should be 0 if formvalue is unique$unique = mysql_num_rows($result);if ($unique > 0){ $error = $formvalue. "Already in use"; return($error);}//Return true if $formvalue is unique//return("true");//} ?>[/code]EDIT - [b]Please[/b] use the CODE buttons to make your code easier to read. Indenting conditionals would be even better. Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-38054 Share on other sites More sharing options...
genista Posted May 23, 2006 Author Share Posted May 23, 2006 Any help on this would be greatly appreciated guys.Thanks,G Quote Link to comment https://forums.phpfreaks.com/topic/9807-include-file-problems/#findComment-38290 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.