Jump to content

teddy777

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

teddy777's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I put my code through a syntax checker(everything OK), but due to it being in my html code if the code went wrong and I included your code to report errors I still can't see them.
  2. sorry that was an error copying the code to here, I did include quatation marks in my real code
  3. hi i'm trying to include text from a file on my webpage, i want to continually change this file so I can't just write it in html. This is the code I've tried so far, it didn't work <?php $file = file_get_contents(filename.txt); echo $file; ?>
  4. I get this when i fill out a form and submit it to my database. Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0. I've got my php code, this is my first one so its fairly crap. myusername=$_POST['myusername']; $password1=$_POST['password1']; $password2=$_POST['password2']; $myemailaddress=$_POST['email']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername'"; $result=mysql_query($sql); if($_POST['submit']){ //username checking if($myusername && strlen($myusername) >= 3){ $query = mysql_query("SELECT `id` FROM `tutreg` WHERE `username`='". $myusername."' LIMIT 1"); if(mysql_num_rows($query)){ $error['userexists'] = 'Username exists'; } } else { $error['usernameinput'] = 'Please enter a username of 3+ characters'; } //email checking if($myemailaddress){ if(!eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", $myemailaddress)){ $error['emailerror'] = 'Email Incorrect'; } } else { $error['emailinput'] = 'Please supply an email address'; } //Password checking if($password1 && $password2){ if($password1 != $password2){ $error['passmismatch'] = 'Passwords don\'t match'; } } else { $error['passwordinput'] = 'Please enter your password in both fields'; } } if(!$error && $_POST['submit']){ $sql = mysql_query("INSERT INTO `tutreg` (username, password, email) VALUES ('".$myusername."', '".md5($password1)."', '".$myemailaddress."')"); if($query){ echo $myusername .' is now registered'; } } // Free memory mysql_free_result($result); ?>
  5. thanks that worked, sorry it was such a trivial error
  6. I get this error when checking my syntax, common causes seem to be missing a semi colon from the code, causing it to try and parse the line after the last line of the file or misspelling a variable. I'm not sure so, does any body know how to fix this. <?php // Connect to server and select databse. ; mysql_select_db('---')or die('cannot select DB'); $myusername=$_POST['myusername']; $password1=$_POST['password1']; $password2=$_POST['password2']; $myemailaddress=$_POST['email']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername'"; $result=mysql_query($sql); if($_POST['submit']){ //username checking if($myusername && strlen($myusername) >= 3){ $query = mysql_query("SELECT `id` FROM `regtut` WHERE `username`='". $myusername."' LIMIT 1"); if(mysql_num_rows($query)){ $error['userexists'] = 'Username exists'; } } else { $error['usernameinput'] = 'Please enter a username of 3+ characters'; } //email checking if($myemailaddress){ if(!eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", $myemailaddress)){ $error['emailerror'] = 'Email Incorrect'; } } else { $error['emailinput'] = 'Please supply an email address'; } //Password checking if($password1 && $password2){ if($password1 != $password2){ $error['passmismatch'] = 'Passwords don\'t match'; } } else { $error['passwordinput'] = 'Please enter your password in both fields'; } } if(!$error && $_POST['submit']){ $sql = mysql_query("INSERT INTO `regtut` (username, password, email) VALUES ('".$myusername."', '".md5($password1)."', '".$myemailaddress."')"); if($query){ echo $myusername .' is now registered'; } ?> this is my code its my first ever attempt at php an a login code so its a bit cobbled together.
×
×
  • 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.