Jump to content

TechnoDiver

Members
  • Posts

    203
  • Joined

  • Last visited

Everything posted by TechnoDiver

  1. Can someone please tell me why neither one of these are working: $content = str_replace(array("\r", "\n"), '', $row['content']); $content = preg_replace( "/\r|\n/", '', $row['content']); I've tried each one of the to replace $content = $row['content']; and for some ungodly reason neither one of them are working. This is simply pulling content from a database but it keeps displaying \r\n when displayed in a page. Why?
  2. ahh, bro, thank you so much. That was driving me crazy, and it makes so much more sense now. I was simply passing the wrong variable into the database. I simply had to change this -> $post_obj->addNews( $_POST['title'], $_POST['content'], $_POST['category'], $_POST['status'], $_POST['post_type'], $_POST['tags'], $target_file ); to this -> $post_obj->addNews( $_POST['title'], $_POST['content'], $_POST['category'], $_POST['status'], $_POST['post_type'], $_POST['tags'], basename($file_new_name) ); The last database parameter. and then add 'img/posts/' before the $image call in the HTML, obviously. But thinking of it the way you said helped and makes total sense. Thanks again
  3. Ok, the actual full path is '/opt/lampp/htdocs/qcic/newsnet/img/posts/' The add_post.php file is in '/opt/lamp/htdocs/qcic/usernet/content/add_post.php', so the common path for them is '/opt/lampp/htdocs/qcic/' This is my code at the top of add_post.php and I see no reason why it would want to dl elsewhere -> <?php require("assets/initializations.php"); mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; echo "this is the file temp name " . $file_tmp_name . "<br>"; $file_ext = explode('.', $filename); $file_act_ext = strtolower(end($file_ext)); $allowed = array('jpeg', 'jpg', 'png', 'gif'); if(!in_array($file_act_ext, $allowed)) { echo "<script>alert('File Type Not Allowed');</script>"; //not sure how well this size check is working, have to experiment more //also need to research how to do an initial image check } elseif($filesize > 10000000) { echo "<script>alert('Image Is Too Large');</script>"; } else { $file_new_name = uniqid('', true) . "." . $file_act_ext; $dir = "/newsnet/img/posts/"; $target_file = $dir . basename($file_new_name); echo "this is the target file " . $target_file; move_uploaded_file($file_tmp_name, $target_file); $post_obj->addNews( $_POST['title'], $_POST['content'], $_POST['category'], $_POST['status'], $_POST['post_type'], $_POST['tags'], $target_file ); echo "<script>alert('Your Post Has Been Added');</script>"; echo $target_file; // mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); } } You'll see that $dir is where I've been experimenting with the path and there's some unnecessary echo statements I was confirming things with. It doesn't yet handle any other uploads. It's meant to rename the image, move it into the sites directory structure and then send the link to it into the DB with the rest of the user input. It does that, so far so good.. This is the method that handles that -> public function addNews($title, $content, $category, $status, $type, $tags, $image) { if(!empty($title) && !empty($content)) { $title = strtoupper($title); $title = mysqli_real_escape_string($this->conn, $title); $content = nl2br($content); $content = mysqli_real_escape_string($this->conn, $content); $added_by = $this->user_obj->getUsername(); $query = mysqli_query($this->conn, "SELECT top_cat_id FROM top_categories WHERE top_cat_title='$category'"); $row = mysqli_fetch_array($query); $cat_id = $row['top_cat_id']; $date_added = date('Y-m-d H:i:s'); //these may have to be moved/assigned somewhere else eventually $num_likes = 0; $num_comments = 0; $num_views = 0; $statement = $this->conn->prepare("INSERT INTO news ( title, content, add_by, post_category, post_cat_id, post_image, tags, status, type, num_likes, num_comments, num_views, date_added ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?);"); $statement->bind_param('ssssissssiiis', $title, $content, $added_by, $category, $cat_id, $image, $tags, $status, $type, $num_likes, $num_comments, $num_views, $date_added); if($statement) { $statement->execute(); } } } And again, I see nowhere that there's a clash of download locations or the like. I hate flooding one post with a bunch of code, but there is another method involved with displaying these images -> public function getBreakingNews() { $query = mysqli_query($this->conn, "SELECT * FROM news WHERE type='breaking' ORDER BY RAND()"); $str = ""; while($row = mysqli_fetch_array($query)) { $id = $row['id']; $title = $row['title']; $content = $row['content']; // if(strlen($content) > 200) { // $content = substr($content, 0, 200) . "..."; // } $added_by = $row['add_by']; $cat_title = $row['post_category']; $cat_id = $row['post_cat_id']; $image = $row['post_image']; $likes = $row['num_likes']; $comments = $row['num_comments']; $date_added = $row['date_added']; $current_datetime = date("Y-m-d H:i:s"); $start_count = new DateTime($date_added); $end_count = new DateTime($current_datetime); $interval = $start_count->diff($end_count); // $image = substr($image, 13); echo $image; if($interval->h <= 8) { $str .= " <div class='single-blog-post small-featured-post d-flex'> <div class='post-thumb'> <a href='#'><img src='$image' alt=''></a> </div> <div class='post-data'> <a href='#' class='post-category text-size-6'>$cat_title</a> <div class='post-meta'> <a href='#' class='post-title'> <h6>$title</h6> </a> <p class='post-date'><span>Hour:minute</span> | <span>month:day</span></p> </div> </div> </div>"; } } // mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); echo $str; } } and again, this one works fine for everything except the image. So I realize I've got something not happening correctly, but I've been working on this issue on and off since last weekend and I can't get those images displayed. It's why I kept mentioning the browser console output, but I understand why the underlying cause should be the focus..
  4. There are a few test entries that have stored the path "site/news/img/posts/" yes. That was actually the original way I tried in the beginning. The problem then is not only does the browser console say it's looking for it in "http://localhost/site/news/site/news.." repeating the /site/news/ segment but I also get these warnings: and the data still goes into the database. The only way I was able to get this resolved was by using the full path -> /opt/lampp/htdocs/site/newsnet/img/posts/ So by not putting in the full path I have 2 issues and with the full path I have the issue of redundant path segments. And I've no idea why. When I echo the contents of the variable that I push into <img src= ...> (where it should display the image and isn't) it echos just the full path with no repeated segments but the browser console returns the paths with repeated segments. So I'm pretty lost as to how to fix it
  5. I mentioned in my first response that I tried dropping the /opt/lampp/htdocs/ and when I only use /site/news/img/posts/ the browser looks in "https://localhost/site/news/site/news/img/posts/. So on both methods there's a section getting repeated.
  6. Yea, I originally had it fully hard coded in as in my OP -> "/opt/lampp/htdocs/site/news/img/posts/" and the browser looks for the images in "http://localhost/opt/lampp/htdocs/site..." So after my OP I tried $_SERVER['DOCUMENT_ROOT'] . /site/news... the browser still looks for it in "http://localhost/opt/lampp/htdocs/site..." The really confusing part is if I only hard code the path -> "/site/news/img/posts/" dropping the "/opt/lampp/htdocs/" part then the browser looks for it in "http://localhost/site/news/site/news/img/post/" So either way I get a repetitive path segment and I have no idea why or how to fix it
  7. I'm trying to display some user created content on a page. Everything does what it should except the image (it's always the image). To be clear, I'm not storing the image in the DB only the link to the image, but images are being uploaded into the site file system. The path being stored in the DB (phpmyadmin) is the full image path - /opt/lampp/htdocs/site/news/img/posts/* - The image doesn't display on the page and I get a 404 not found in the console. When I echo the path to the page that it's looking for the image in, it's as above. But the 404 not found in the console says it's looking for it at http://localhost/opt/lampp/htdocs.... So it's obviously got a redundant section (http://localhost). When I try to remove the /opt/lampp/htdocs from the upload path I get a bunch of warnings. But the real issue is that the browser is adding the repeated section. So how do I remedy this so the browser looks in the correct location? TIA
  8. I've attempted to and unless there's a way to check it outside browser input I can't right now as the button doesn't do anything. I choose the image, hit resize and the button changes color per css to active state but doesn't do anything, just sits there. I can't get any output from anything with it. and this is what happens after clicking resize - nothing except the changed button appearance What I also tried to do is to echo $ext (which is the outside $image_ext parameter) from inside the class method, but as I said nothing gets returned at all.
  9. I am using $_FILES for the upload. public function imageUpload() { $image_name = $_FILES['get_image']['name']; $image_temp_loc = $_FILES['get_image']['tmp_name']; $image_size = $_FILES['get_image']['size']; $image_type = $_FILES['get_image']['type']; $image_error = $_FILES['get_image']['error']; //error handling if(!$image_temp_loc) { echo "ERROR: You forgot to choose a file"; exit(); } else if($image_size > 5242880) { echo "ERROR: Your image is more than 5 Megabytes"; unlink($image_temp_loc); exit(); } else if(!preg_match("/\.(gif|jpeg|jpg|png)$/i", $image_name)) { echo "ERROR: This page is only for images"; unlink($image_temp_loc); exit(); } else if($image_error) { echo "ERROR: An error occurred. Something's fucked up."; exit(); } $move_image = move_uploaded_file($image_temp_loc, "/opt/lampp/htdocs/site/admin/img/$image_name"); if(!$move_image) { echo "ERROR: File not uploaded. Something's fucked up."; unlink($image_temp_loc); exit(); } Uploading works fine. It's the resize button that isn't working. The only time I've used $_POST here is to determine the states of the buttons on the actual page. Unless I'm misunderstanding what your saying..
  10. Good Morning, Freaks, I hope you're all well. I've a question - I've been researching coding image resize functionality. While looking into the functions I'd need to do this I came across very similar code used in examples from 3 different sources so decided this was good code to learn from. So I tweeked it a bit and put it into a class method -> public function imageResize($target, $newcopy, $w, $h, $ext) { list($orig_w, $orig_h) = getimagesize($target); $scale_ratio = $orig_w/$orig_h; if(($w / $h) > $scale_ratio) { $w = $h * $scale_ratio; } else { $h = $w / $scale_ratio; } $img = ""; if($ext == "gif" || $ext == "GIF") { $img = imagecreatefromgif($target); } else if($ext == "png" || $ext == "PNG") { $img = imagecreatefrompng($target); } else if($ext == "jpg" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG") { $img = imagecreatefromjpeg($target); } $create_tci = imagecreatetruecolor($w, $h); imagecopyresampled($create_tci, $img, 0, 0, 0, 0, $w, $h, $orig_w, $orig_h); imagejpeg($create_tci, $newcopy, 80); } and then connected it to a button -> <?php require("assets/initializations.php"); if(isset($_POST['upload_image'])) { $image_obj = new Image($conn, $user); $image_obj->imageUpload(); } else if(isset($_POST['resize_image'])) { mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $image_obj = new Image($conn, $user); $kaboom = explode(".", $image_name); //object params $image_ext = $kaboom[-1]; $target_image = "/opt/lampp/htdocs/site/admin/img/$image_name"; $resized_image = "/opt/lampp/htdocs/site/admin/img/resized_$image_name"; $max_w = 150; $max_h = 150; $image_obj->imageResize($target_image, $resized_image, $max_w, $max_h, $image_ext); //header("Location: add_photo.php"); } ?> Setup: A preview button chooses the image, a preview which is displayed underneath it (using js). There's also an upload button to bring it into the sites file system. This functionality works fine. I've just added the resize button beside the preview button and connected the object method to it. Intended Result: The resize button resizes the previewed image and the resized image is now previewed instead of the original image. Result: Nothing. The button stays in the active state, but nothing happens. I get no warning nor error messages and absolutely nothing in dev tools to work from. Not sure what my next step would be outside asking more experienced coders Any advise or guidance on getting this resolved would be met with appreciation. TIA
  11. so, for example, I shouldn't close off the code in Classes? I remember Barand said something like that a few weeks ago to me and I didn't quite understand what he meant. Now I do. Thank you
  12. UPDATE: The resolution to this problem was moving all the class instantiations from the initializations.php file to the top of their respective pages. It seems real obvious in hindsight. I feel I think more clearly in the evenings. I still don't know where that header from 1981 is from, if anyone has any info on that I'd like to hear it
  13. Ok, that certainly adds to the list of new things to learn concerning this project, I appreciate it and will look into it. I'm so confused as to why this is even a conflict, I've been staring at it and changing small things since I made the OP. I've moved the post_obj instantiation out of the initializations.php file and put it in an if statement at the top of the add_posts.php file. So Post.php should only be being touched if $_POST['add_post'] is set. There's no 'add_post' in the file this is giving the header warning about. <?php require("assets/initializations.php"); mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $post_obj = new Post($conn, $user); $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; ..... ..... so now the $post_obj isn't even a thing at the time it's saying it's throwing out that header. And add_post.php is working as intended. What am I missing?
  14. Good morning folks, I'm having an obscure issue with previously sent headers. I have an add_category.php for the admin backend of an app I'm working on. It was working fine until I added a Post.php class, but the Post.php class doesn't even interact with add_categories.php outside the initialization file. When I use this file to add a category I get the normal Like I said, this was working fine until I added the Post.php class. But the only time that they even come close to interacting is in the initializations.php which I put at the top of each of the pages and looks like this -> <?php require("../load.php"); require("../assets/class/User.php"); require("../assets/class/Category.php"); require("../assets/class/Post.php"); $user = $user_obj->getUsername(); $role = $user_obj->getRole(); $cat_obj = new Category($conn, $user); $post_obj = new Post($conn, $user); The relevant code for the add_category.php is -> <?php require("assets/initializations.php"); if(isset($_POST['add_cat'])) { $cat_obj->addCategory($_POST['cat_title']); header("Location: category.php?message=category-added"); exit; } ?> After some research I've altered this a bit to this -> <?php require("assets/initializations.php"); if(isset($_POST['add_cat'])) { $cat_obj->addCategory($_POST['cat_title']); if(!headers_sent()) { header("Location: category.php?message=category-added"); exit; } else { var_dump(headers_list()); } } ?> Which returns this -> I have no idea where those are coming from or why they're coming at all and that date is a long time ago. Some of it looks familiar, some I've never seen before. I haven't come across a remedy that works yet though. Any suggestions? EDIT: typo
  15. Yea, thanks for your input. I'm frustrated with it right now and will figure it out this week. I've found a new issue to contend with that if I can't figure out tonight will probably bring me back here tomorrow. Thanks again
  16. Sorry about the double post, I unintentionally hit submit after my last edit and it wouldn't let me edit again. So if I exchange which directories each font-awesome.min.css file is in then the icon doesn't show up on either page, but if I put them back then the icon is shown on the page it was shown on. The file structure with all the possible dependencies are the same. I've no clue how to proceed getting this icon to display on other pages. Again, it's not a matter of life or death but something I would like to tie up loose ends on
  17. Yea, I've done all that before even asking about it here. It was during that frustration that I remembered there's a CSS forum here. I'll try explaining it - file A - is the one that shows the newspaper icon successfully on the one page. file B is the one that won't show the icon page B is the page I'm working on now that I want to use the icon again on When I connected both file A and file B to page B nothing changes, still can't use that icon. When I commented out the import to file B to only use file A all icons disappeared. I started thinking about dependencies, so I just brought the entire css directory that enveloped file A into the directory of page B I'm working in. Now they all work except the newspaper one again. It's confusing and I see no reason for it. Because I'm working from a highly customized template I was thinking there may be some dependencies in action that I wasn't aware of, which brought me here. As far as moving and connecting files around, I've done it all for hours last night. The only thing I haven't done yet, intentionally is use the CDN link but that seems like running from the challenge and I'll use that as a last resort. EDIT: I just double checked to see if what I said I did last night was accurate. If I move the font-awesome file from the directory that won't show the newspaper icon then it shows no icons. If I move the one that works into the directory where I can't get the icon it still doesn't show that icon. And if I remove the working one from where it is showing the icon then no icons appear. So the font-awesome files are affecting each directory the same with the exception of this one icon. It's baffling me
  18. yea, they're both font-awesome.min.css and probably not different. I don't see why they would be different, it just seems that way because I've literally got all the same files connected to the 2 different pages and I can't get the one specific icon to work on one page. It's even listed as free on their website, it's just that one icon and it's working on a different page so it's weird. I know it's not the exact theme of this specific forum but I thought there may have been an obscure bit I was overlooking. Literally everything is the same and it only works on one page. The site isn't viewable right now, but when it is I'll gladly share it here as I've received so much help here
  19. I'm pretty sure this is the correct forum to ask this, it's my first time posting outside of the PHP forums. I'm building (trying to build) a web app, it's pretty much a practice project so I'm not ready or able to invest in font awesome pro so I've been using their free icons. The issue I'm inquiring about is the font-awesome.min.css file. I've used it in one file and am able to use a certain icon which is listed as a free icon, but I'm not able to get the icon to appear in other places that are linked to the same file. The icon in question is "fa fa-newspaper" icon, if that makes a difference. I can use it in one area of the app but not in another. I suspected I'm using 2 different font-awesome.min.css files. (the project started with a template that I have expanded and customized beyond recognition) but no matter how much I move them around and link them I can't get that one icon to work anywhere else on the app. Nothing I find in searching around tackles this, and it seems like such a silly thing. So I'm wondering if anyone has any input or some knowledge/experience that could answer this question for me. (I'm aware that font-awesome probably has some dependencies so instead of linking to existing files I've tried to copy the file structure into it's own directory) That particular icon still doesn't work, it's not a matter of life and death but it's baffling. So I'm wondering if anyone can explain this to me. TIA
  20. Ok, Thanks again folks here. I knew I shouldn't have had the ? in '' but for some reason I did it anyways. What I didn't know was that I couldn't pass those 0 integers in the bind_param as literals and they needed to be passed as variables. Thanks for the help, I've learned a lot from you folks here
  21. Yea, you're right, I was thinking it may have been explainable without the code here is the amended addNews method -> public function addNews($title, $content, $category, $status, $type, $tags, $image) { if(!empty($title) && !empty($content)) { $title = strtoupper($title); $title = mysqli_real_escape_string($this->conn, $title); $content = nl2br($content); $content = mysqli_real_escape_string($this->conn, $content); $added_by = $this->user_obj->getUsername(); $query = mysqli_query($this->conn, "SELECT top_cat_id FROM top_categories WHERE top_cat_title='$category'"); $row = mysqli_fetch_array($query); $cat_id = $row['top_cat_id']; $date_added = "todays date"; $statement = $this->conn->prepare("INSERT INTO news ( title, content, add_by, post_category, post_cat_id, post_image, tags, status, type, num_likes, num_comments, num_views, date_added ) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?');"); $statement->bind_param('ssssissssiiis', $title, $content, $added_by, $category, $cat_id, $image, $tags, $status, $type, '0', '0', '0', $date_added); if($statement) { $statement->execute(); } else { echo "You messed up somewhere"; }
  22. Yea, that got me an error that time. I saved that line of code when you taught it to me a month or so ago and was using it but I guess in the wrong place. That got me an error when I moved it. I decided I'd just make it a full prepared statement first and then fix it after that. I'm trying to work out this new error -> Is this error referring to the 11th argument in the prepared statement? I'm not sure what it's saying. It might sound silly but if that's what it means it's really weird because the 10th, 11th and 12th parameters are all integers set to zero right now, but it's only referencing the 11th
  23. I've been trying to write some code that takes user supplied information, sends it to a database (phpmyadmin) and also displays it elsewhere in the app. I'm to the point I'm trying to get it to the database right now. The issue is that it's not making it to the DB and is being lost somewhere. There's no warnings, no errors, nothing being returned anywhere to help resolve the problem, except in the browsers dev tools and that is different whether it's chrome or FF. It's also something that I have trouble seeing being responsible for the loss of data. In Chrome it comes back as -> Page layout may be unexpected due to Quirks Mode In FF as -> Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. But, like I said, I can't see how this is to blame for the data not making it to the DB and I see no difference in the layout or style anyways. At the top of add_post.php is the following: <?php require("assets/initializations.php"); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; $file_ext = explode('.', $filename); $file_act_ext = strtolower(end($file_ext)); $allowed = array('jpeg', 'jpg', 'png', 'gif'); if(!in_array($file_act_ext, $allowed)) { echo "<script>alert('File Type Not Allowed');</script>"; //not sure how well this size check is working, have to experiment more //also need to research how to do an initial image check } elseif($filesize > 10000000) { echo "<script>alert('Image Is Too Large');</script>"; } else { $file_new_name = uniqid('', true) . "." . $file_act_ext; $dir = "/opt/lampp/htdocs/qcic/usernet/img/"; $target_file = $dir . basename($file_new_name); move_uploaded_file($file_tmp_name, $target_file); $post_obj->addNews( $_POST['title'], $_POST['content'], $_POST['category'], $_POST['status'], $_POST['post_type'], $_POST['tags'], $target_file ); echo "<script>alert('Your Post Has Been Added');</script>"; mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); } } ?> <?php require('includes/header.php'); ?> Most of it is handling the image. The Post and User objects are instantiated in initializations.php at the top. The image uploads fine, everything works except the post object. The class for that is -> <?php class Post { private $conn; private $user_obj; public function __construct($conn, $user) { $this->conn = $conn; $this->user_obj = new User($conn, $user); } public function addNews($title, $content, $category, $status, $type, $tags, $image) { if(!empty($title) && !empty($content)) { $title = strtoupper($title); $title = mysqli_real_escape_string($this->conn, $title); $content = nl2br($content); $content = mysqli_real_escape_string($this->conn, $content); $added_by = $this->user_obj->getUsername(); $query = mysqli_query($this->conn, "SELECT top_cat_id FROM top_categories WHERE top_cat_title='$category'"); $row = mysqli_fetch_array($query); $cat_id = $row['top_cat_id']; $statement = $this->conn->prepare("INSERT INTO news VALUES ('', '$title', '$content', '$added_by', '$category', '$cat_id', '$image', '$tags', '$status', '$type', '?', '?', '?', '?');"); if($statement) { $statement->execute(); } else { echo "You messed up somewhere"; } } } } ?> I'm not the best or most experienced coder, for sure, but in the few months I've been learning PHP I've written a few DB queries now and this looks right to me. The first attempt didn't have prepared statements but that wasn't getting the data to the DB either. I've checked that the number of fields being sent match the number of fields in the DB, been tinkering with a few small things since yesterday on it, nothing works and as I said, no error or warning is coming back to work from, no message at all to work from. The only thing it triggers is those 2 console messages I mentioned above and the image does get to its new location. It's to the point now I'm just blank-mindedly staring at code. I'm not even getting back the else echo "You messed up somewhere" error from the final if statement, just the javascript alert that it was sent correctly, which it wasn't. I can really use some guidance on this one, thank you
  24. Alright, thanks. I knew about $_FILES but I didn't realize that the values didn't pass into $_POST too
  25. I'm getting an undefined array key warning from an array key that has been defined like the other keys in the array. The method call is as follows: $post_obj->addNews( $_POST['title'], $_POST['content'], $_POST['category'], $_POST['status'], $_POST['post_type'], $_POST['tags'], $_POST['post_image'] ); The method and class are: class Post { private $conn; private $user_obj; public function __construct($conn, $user) { $this->conn = $conn; $this->user_obj = new User($conn, $user); } public function addNews($title, $content, $category, $status, $type, $tags, $image) { if(!empty($title) && !empty($content)) { $title = strtoupper($title); $title = mysqli_real_escape_string($this->conn, $title); $content = nl2br($content); $content = mysqli_real_escape_string($this->conn, $content); $added_by = $this->user_obj->getUsername(); $query = mysqli_query($this->conn, "SELECT top_cat_id FROM top_categories WHERE top_cat_title='$category'"); $row = mysqli_fetch_array($query); $cat_id = $row['top_cat_id']; $insert_sql = mysqli_query($this->conn, "INSERT INTO news VALUES ('', '$title', '$content', '$added_by', '$category', '$cat_id', '$image', '$tags', '$status', '$type', '0', '0', '0', '0');"); } } } the relevant HTML is: <div class="form-group"> <label>Image</label> <input type="file" name="post_image" accept="image/*" onchange="preview_image(event)" value="Choose Image"> <br> <label>Image Preview</label><br> <img class="img-rounded" id="output_image" width="150" height="150" /> </div> The warning is an undefined array key on 'post_image'. But it's been defined like all the others. There's nothing I could find relevant to this and I'm lost. Is the problem because it's an image? I see no reason why 'post_image' remains undefined. If anyone feels like looking it over, I always appreciate the extra direction, I'm lost on this
×
×
  • 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.