Jump to content

Silence~

Members
  • Content Count

    21
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Silence~

  • Rank
    Newbie
  • Birthday 12/21/1996

Profile Information

  • Gender
    Male
  • Location
    SG
  1. I'm having trouble with getting the image in the right order. I'm trying to filter images gotten from the database based on the button link. I got the reference from http://www.evoluted.net/thinktank/web-development/jquery-filtering. I have about 20+- buttons and for each button, I am getting all the picture that is being under that filter button through database. (Not sure where to post this, but I think it's more suited to be under css). Basically, I have gotten the css all wrong (my css is basic too ><), so I hope you could help me(where i have gone wrong) and give some pointers. Her
  2. ...There's no errors, it works fine now. Somehow my data got deleted away in my database.. :| So, it was actually my data that is not there in the first place? But it was there when i tried yesterday ><
  3. I'm not sure what you mean by this, I put var_dump($database) and var_dump($statement) and this is the results: object(PDOStatement)#2 (1) { ["queryString"]=> string(99) "SELECT * FROM userProfile WHERE user_id in ( select id from users where id = 1)" }
  4. Hmm it still give the same dump: object(PDO)#1 (0) { } ;-; I'm confused why though
  5. Nope I didn't. I get the error message beside the one I stated above: if (!$row = $statement->fetch(PDO::FETCH_ASSOC)) { print_r ("No Data to show. Please add in your profile. Navigate your way through the left side of the page where the navigations are.");} Oh okay, thanks for the explanation
  6. My database file looks like this: try {$user = ""; //taken out just in case$pass = "";$database = new PDO('mysql:host=localhost;dbname=final_year_project_1;charset=utf8', $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false,PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));}catch (PDOException $ex) { echo 'Connection failed: ' . $ex->getMessage();} When you mean open the connection, i just have to require the file right? Must I put it in the try catch?(because I already put it in the database file?) or like put the search code and the select code together? I cl
  7. Ah yes, thank you! This was one of the cause >< But why would that affect though? I thought by requiring the database connection again, it should be okay?Anyways, it gives this: object(PDO)#1 (0) { } for the vardump. I have data inside though?
  8. Tried it and it says null. Does that mean my database connection being null or my query being null? It works though if i didn't put the search code in.. o.o
  9. I'm receiving this error 'Call to a member function prepare() on null' if I were to put this search code into the page. It works fine if i were to put at other pages(for inserting to database).Here's my search code that I've put before the html tags: <?php//echo '<pre>';//echo $_POST;//echo '</pre>';//declare the form name//$searchForm = htmlentities($_SERVER['PHP_SELF']);try { //inserts database connections require('Connections/database.php'); if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['search'])) { // array to hold errors $errorsSearch = array(); //
  10. My apologies. It actually does show the errors, just that it was hiding under my navigation bar. I sorted it out already. Thank you for all the help I need ^^ [is there any way I can mark this as answered?]
  11. Okay, I found out the solution to that error.. I utterly embarrassed myself for not looking through thoroughly >< With the help of this post : http://w3schools.invisionzone.com/index.php?showtopic=47997&p=265892 , I realised I had moved my coding to the starting of html form and that what caused the error since the header location must be located before the html tag. Thanking Ingolme indirectly (Thanks a bunch ) . Anyways, I still can't validate if the file is not image. It won't show the $errors[] either. >< I'm not sure where i go wrong o,o
  12. I'm not sure if i understand it correctly. This is what I've added in : //Allowed typpes to pass through validation $allowedTypes = array('image/jpg', 'image/jpeg', 'imagae/jpe', 'image/png', 'image/gif'); $allowedExtensions = array('jpg', 'jpeg', 'jpe' , 'png', 'gif'); //$ext = explode(".", $filename); // $extension = strtolower(end($ext)); //gets the info of ther file, in this case, extension $extension = pathinfo($filename, PATHINFO_EXTENSION); //return the file mime type $finfo = new finfo(FILEINFO_MIME_TYPE); //check th file for the information (tmp or name) $mimetype = $finf
  13. I did another try(before you posted this) and I'm stuck at the same place where they would not detect the extension. Here's my tries : //First Try//tried with 'jpg','png' and 'gif' for both too$allowedTypes = array('image/jpg', 'image/png', 'image/gif'); $ext = explode(".", $filename);$extension = strtolower(end($ext));$finfo = new finfo(FILEINFO_MIME_TYPE);$mimetype = $finfo->file($filetmp);var_dump($mimetype);if (!in_array($mimetype, $allowedTypes) || !in_array($extension, $allowedTypes)) { $errors[] = ('File uploaded does not meet the types criteria(PNG/JPG/GIF). Please check.');}el
  14. So, I tried coding for the image uploading and I have some difficulty on the MIME type. If I did not declare anything of that, I am able to insert to the database(the directory and the name of the file) but the picture would not be inserted to the folder. This are my code: //Declare variables and start validation $fileMaxSize = $_POST['MAX_FILE_SIZE']; $filename = $_FILES['userfile']['name']; $filetype = $_FILES['userfile']['type']; $filesize = $_FILES['userfile']['size']; $filetmp = $_FILES['userfile']['tmp_name']; $fileError = $_FILES['userfile']['error']; $uploaddir = '/profilePi
×
×
  • Create New...