Jump to content

AjACK

New Members
  • Posts

    4
  • Joined

  • Last visited

AjACK's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I get the second error message. Something went wrong
  2. So I made a working image uploading script it saves it to a database, now it works perfectly fine in PC but when you are on mobile device it won't allow images to be uploaded. I think I added all the right image types not sure if this is a code issue or something else any help would be great! <?php require_once "config/config.php"; db_connect(); check_auth(); $msg = ''; $id = $_SESSION['id']; if($_SERVER['REQUEST_METHOD'] == 'POST') { $tmpName = $_FILES['pro_img']['tmp_name']; //read the file $fp = fopen($tmpName, 'r'); $pro_img = fread($fp, filesize($tmpName)); fclose($fp); if(($_FILES['pro_img']["type"] == "image/jpeg" || $_FILES['pro_img']["type"] == "image/png" || $_FILES['pro_img']["type"] == "image/pjpeg" || $_FILES['pro_img']["type"] == "image/X-PNG" || $_FILES['pro_img']["type"] == "image/svg+xml")) { $sql = "Update accounts SET pro_img = ? WHERE id = ?"; $statement = $conn->prepare($sql); $null = NULL; $statement->bind_param('bi', $null, $id); $statement->send_long_data(0, $pro_img); $statement->execute(); $check = mysqli_stmt_affected_rows($statement); if($check == 1){ redirect_to("dashboard.php?img=uploaded"); $msg = 'Image was uploaded'; }else{ redirect_to("dashboard.php?img=failed"); $msg = 'Something went wrong!'; } }else{ redirect_to("dashboard.php?img=wrong_type"); $msg = 'File type not supported'; } } ?>
  3. this is where the link is being generated for the "comment" I'm sure this is where the issue is coming into play. Been a long time since I've used php learned it around 1998 eek I feel old an PHP has changed quite a bit since then. But alas I'm not above learning and honing my skills. As far as database column names it's the easiest way for me to know what each column means. I know ID = user id post_id = the ID of the post reply_id = the ID of the reply so on so forth. My brain wouldn't be able to handle if I had tables with the name ID in them but unsure which ID it was representive of how would I know that ID was for post_id or for comment_id etc etc. Unless I am misunderstanding you lol it's possible.
  4. I am working on a commenting system for my website I am having some issues. As of right now user can comment and "reply" but the issue is coming in with the replies. I can't get the post_id to associate with the reply table of my comment. There is a table called `posts` has post_id-id of the post id-id of the user who made the post created_on-time stamp of post creation content-text of the post or images, videos etc. There is a table called `replies` has reply_id-id of the reply id-id of user who made the reply created_on-time stamp of reply content-text of the reply post_id-this is the post that the user is replying to this is where we are running into issues. Here is the code that I am working on. PHP using MySQLi prepared statements. this is the comment.php file <?php require_once "config/config.php"; include "functions.php"; db_connect(); check_auth(); $sql = "INSERT INTO replies (id, post_id, content) VALUES(?,?,?)"; $statement = $conn->prepare($sql); $statement->bind_param('isi', $_SESSION['id'], $_POST['content'], $_GET['post_id']); if($statement->execute()) { redirect_to("dashboard.php"); }else{ redirect_to("dashboard.php?error=true"); } this is the section where the user can trigger the reply code $result = get_posts($conn); if($result->num_rows > 0 ) { while($post = $result->fetch_assoc()) { $sql = "SELECT id, first_name, last_name, pro_img FROM accounts WHERE id = ? LIMIT 1"; $statement = $conn->prepare($sql); $statement->bind_param('i', $post['id']); $statement->execute(); $statement->store_result(); $statement->bind_result($id, $first_name, $last_name, $pro_img); $statement->fetch(); ?> <!--user posts--> <div class="user_posts"> <label><?php echo '<img src="data:pro_img/jpg;base64,'.base64_encode($pro_img).'" height="50" width="50"/>';?><?php echo ($row['first_name']), ($row['last_name']);?></label> <p><?php echo $post['content'];?></p> <div class="likes"> <button class="like"><i class="material-icons like">favorite</i></button> <button class="like"><i class="material-icons dislike">heart_broken</i></button> </div> <form action="comment.php?post_id=<?php $_GET['post_id'];?>" method="post"> <input type="text" name="content" id="content" required> <input type="submit" name="comment" value="comment"> </form> </div> As you can see I am attempting to use $_GET to get the post_id to associate the reply with the comment but the post_id somehow always being associated with the "id" of the user instead of the id of the post we are trying to reply to. here is the code to get the posts to show on the screen. function get_posts($conn) { $sql = "SELECT * FROM posts ORDER BY posted_on DESC";; $statement = $conn->prepare($sql); $statement->execute(); return $statement->get_result(); } Any kind of help would be much appreciated thank you in advanced.
×
×
  • 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.