Jump to content

angelali

Members
  • Posts

    128
  • Joined

  • Last visited

    Never

Everything posted by angelali

  1. It is working now... I forgot a ' at password...
  2. I get Warning: mysql_num_rows() expects parameter 1 to be resource, string given in C:\xampp\htdocs\cp\register.php on line 40 when I do: if (mysql_num_rows($cnick) > 0) {......................
  3. I made a registration form where I put both email address and username as UNIQUE key in database. I did that to preent duplicate email address and username to enter, and also to check if they have already registered, if yes, then the user will have to choose another email or username. I always do registration form where email address is only the UNIQUE key, but today, I'm putting both email address and username as UNIQUE. However, when I register, it gives me my error message to display when either the email address or username has already registered. Here my from below: <form action="register.php" method="post"> <table width="760"> <tr> <td><label>Your email address:</label></td> <td><input type="email" required size="45" maxlength="50" name="email"/></td> </tr> <tr> <td><label>Confirm your email address:</label></td> <td><input type="email" required size="45" maxlength="50" name="cemail"/></td> </tr> <tr> <td><label>Insert a nickname:</label></td> <td><input type="text" required size="45" maxlength="32" name="nick"/></td> </tr> <tr> <td><label>Insert a password:</label></td> <td><input type="password" required size="45" maxlength="32" name="pass"/></td> </tr> <tr> <td></td> <td><input type="submit" value="Register"/></td> </tr> </table> </form> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if(isset($_POST['email']) && isset($_POST['cemail']) && isset($_POST['nick']) && isset($_POST['pass'])) { $email = mysql_real_escape_string(strip_tags(trim($_POST['email']))); $cemail = mysql_real_escape_string(strip_tags(trim($_POST['cemail']))); $nick = mysql_real_escape_string(strip_tags(trim($_POST['nick']))); $pass = mysql_real_escape_string(strip_tags(trim($_POST['pass']))); if (empty($email) || empty($cemail) || empty($nick) || empty($pass)) { echo 'All fields marked with an asterisk are required!'; } else if (strlen($nick) > 32){ echo 'Your nickname cannot be more than 32 characters!'; } else if (!filter_var($email, FILTER_VALIDATE_EMAIL) || !filter_var($cemail, FILTER_VALIDATE_EMAIL)) { echo 'Your email address is invalid!'; } else if (strlen($email) > 50){ echo 'Your email address cannot be more than 50 characters!'; } else if ($email !== $cemail) { echo 'Your email address does not match!'; } else if (strlen($pass) > 32) { echo 'Your password cannot be more than 32 characters!'; } else { $con = @mysql_connect ('localhost', 'root', '') or die ('A problem has occurred,!'); @mysql_select_db ('db', $con) or die ('A problem has occurred!'); $pen = md5($pass); $register = "INSERT INTO reg (reg_ID, email, nickname, password) VALUES ('NULL', '$email', '$nick', $pen')"; mysql_query($register, $con); if (mysql_errno ($con) > 0) { echo 'Either the email address or the username has already taken!'; } else { echo "Registration Successful like a boss!"; mysql_close($con); } } } } ?> Well, each time I choose to make anew registration when choosing a new email address and nickname, I got this error: Either the email address or the username has already taken!...
  4. Elaborate on what? The header topic or my question?
  5. You dont need headers anymore now to display the image from database... I tried this many times and it works...
  6. Ok, I just want to know what you think, I have a table with 20 columns where one column will store the images database. The images which are being saved are just thumbnail pics, not exceeding 250px as width and height and also, not exceeding 20KB in size. So what do you think? Should I proceed to store the images in database?
  7. OK will change this... Mr Marcus, thank you very much man! I love Canada as well, so sad too far.... I live in the Indian Ocean... I'm new in PHP, well not that new, but I started with it in last December. My objective is not to be professional in it, as I'm more on front-end development than back-end. However, I'm a guy who wants to have at least an Intermediate level of knowledge in different back-end languages rather than mastering a single language. I'm still learning, have a lot to do, I have OO to learn (A real pain this OO), and after that, will touch Ruby... Too sad, ColdFusion is almost dead, else I would master it...as I love it.. Well, I added you as buddy list, thank you again man, you are great prince..
  8. And also for the array_map, can I insert strip_tags as well in it like: $ids = array_map('mysql_real_escape_string', 'strip_tags', $_POST['delete']);
  9. If I have asked you your country, this means I would invite you for a good day on the beach in my country, enjoying some chicks, beers and the sand....because IT IS WORKING PERFECTLY LOLLLLLLLLLL Thank youuuuuuuuuuuuu What should I do with this: else { trigger_error(mysql_error()); // remove once everything is working } You said remove it if it is working properly...
  10. Mr Marcus, where do you live? I mean which country?
  11. No its good now I think, let me check the database, then I will tell you.... give me 5 minutes...
  12. Hey wait....wait.... I think its good, you changed from row to assoc, I changed it to array....wait..
  13. Notice: Undefined index: imgname in C:\xampp\htdocs\troll\includes\images.php on line 53 And the permission denied warning.. I get the notice after correcting your codes earlier, forgot to paste it...when I replied you the previus message
  14. Warning: unlink(images/) [function.unlink]: Permission denied in C:\xampp\htdocs\troll\includes\images.php on line 53 The above the warning message. I set all permissions of my folders as FULL CONTROL on Windows, I don't know why iyt keeps asking this. Secondly, as the query is exeuting the image names which are stored in database, with that query $row['imgname'], I put it in a variable, and assign it to unlink function to delete the image.
  15. Permission denied again I passed 5 hours determining this damn problem, I have even broken 2 bottles because of this...
  16. I updated it... Outside the while loop? I did put it inside, see the last ful codes above...is it wrong?
  17. No its 'images' I changed it from 'upload'
  18. <?php //Connect to database $connect = mysql_connect('localhost', 'root', '') or die ('Connection Failed'); mysql_select_db('imgdatabase', $connect) or die ('Connection Failed'); //Display images $display = mysql_query("SELECT * FROM photos WHERE email='$reg'"); echo "<form action='images.php' method='post'>"; echo "<table> <tr> <th>#</th> <th>Your images</th> <th>Image names</th> <th><input type='submit' value='Delete'/></th> </tr>"; echo "<hr/>"; while($row = mysql_fetch_array($display)) { echo "<tr>"; echo "<td>".$row['img_ID']."</td>"; echo "<td><img src='images/".$row['imgame']."' alt='alt text' width='200' height='150' class='thumb'/> </td>"; echo "<td><a href='images/".$row['imgname']."' target='_blank'>".$row['imgname']."</a></td>"; echo '<td><input type="checkbox" name="delete[]" value="'.$row['img_ID'].'"/></td>'; echo "</tr>"; } echo "</table>"; echo "</form>"; //Delete images details in database if (isset($_POST['delete'])) { foreach ($_POST['delete'] as $delete) { $ids[] = mysql_real_escape_string(strip_tags($delete)); //Delete image in folder $file =$row['imgname'] ; $filedel = "images/".$file; unlink ($filedel); } mysql_query("DELETE FROM photos WHERE img_ID IN (".implode(',',$ids).")"); echo "File deleted"; } mysql_close($connect); ?> Permission Denied again!
  19. As you see, its a file upload system, where images are stored in a folder while its details in database..When the user will click on a button to delete the image, he does that by checking check-boxes, he can delete multiple images by checking check-boxes. The deletion of images in database works PERFECTLY, except it does not delete the respective image/s in the folder... <?php //Connect to database $connect = mysql_connect('localhost', 'root', '') or die ('Connection Failed'); mysql_select_db('imgdatabase', $connect) or die ('Connection Failed'); //Display images $display = mysql_query("SELECT * FROM photos WHERE email='$reg'"); echo "<form action='images.php' method='post'>"; echo "<table> <tr> <th>#</th> <th>Your images</th> <th>Image names</th> <th><input type='submit' value='Delete'/></th> </tr>"; echo "<hr/>"; while($row = mysql_fetch_array($display)) { echo "<tr>"; echo "<td>".$row['img_ID']."</td>"; echo "<td><img src='upload/".$row['imgame']."' alt='alt text' width='200' height='150' class='thumb'/> </td>"; echo "<td><a href='upload/".$row['imgname']."' target='_blank'>".$row['imgname']."</a></td>"; echo '<td><input type="checkbox" name="delete[]" value="'.$row['img_ID'].'"/></td>'; echo "</tr>"; } echo "</table>"; echo "</form>"; //Delete images details in database if (isset($_POST['delete'])) { foreach ($_POST['delete'] as $delete) { $ids[] = mysql_real_escape_string(strip_tags($delete)); } mysql_query("DELETE FROM photos WHERE img_ID IN (".implode(',',$ids).")"); //Delete image in folder $file =$row['imgname'] ; $filedel = "images/".$file; unlink ($filedel); echo "File deleted"; } mysql_close($connect); ?>
  20. If I paste the full codes here, will you see them?
  21. Warning: unlink(images/) [function.unlink]: Permission denied in C:\xampp\htdocs\troll\includes\images.php on line 54
  22. I applied permissions to folder, files etc....
  23. I assigned full control on the folder, read, write etc....but the problem remain... :'(
×
×
  • 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.