Jump to content

Fishcakes

Members
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Fishcakes

  • Rank
    Member
  1. I input the error function here to see what error it's returning //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg . "<br> </br>"; echo "Error : " . $_FILES['file']['error'] . "<br>"; } and the output I get is Updated the thumbnail to sql correctly. Error : Updated the thumbnail to sql correctly. Which is weird as it definite
  2. So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir =
  3. That's great thanks, I'll have to study how this join in sql works
  4. Thanks I knew there would be a much better way to do it I've tried translating the above to mine but getting an sql error can you see what I'm missing? select Threads.id as ThreadId, Title, LEFT(ThreadBody) as body, date_format(Thread_date, '%D %b %Y %l:%i %p') as ftime, count(Posts.IdOfThread) as num_posts from thread Threads Left join post Posts on Threads.id = Posts.IdOfThread group by Threads.id order by Thread_date desc;
  5. So I output the Threads for my forum onto the main screen like so <div class ='grid-container'> <?php //Get the Threads and output them onto the screen in a grid container $query = mysqli_query($conn, "SELECT * FROM Threads order by id desc") or die (mysqli_error($conn)); $GetPostsQuery = mysqli_query($conn, "SELECT Count(*) FROM Posts") or die (mysqli_error($conn)); while ($row = mysqli_fetch_array($query)) { $imageURL = 'upload/Thumbnails/'.rawurlencode($row["filename"]); $PostBody = nl2br($row['ThreadBody']); echo " <div class ='grid-item'> &l
  6. I also tried declaring the variable ($testvar) outside the echo statement but the page still won't load even then while ($row = mysqli_fetch_array($query)) { //May need this later to output pictures // $imageURL = 'upload/'.rawurlencode($row["filename"]); $testvar = nl2br({$row['CommentText']}) ; echo " <div class='divTableRow'> <div class='divTableCell'>{$row['User']} ;</div> <div class='divTableCell'> $testvar ;</div> </div> \n"; } echo $_SESSION['id'] ; ?>
  7. Yes I tried this using single quotes which just outputs it as a string <div class='divTableCell'> ' . nl2br({$row['CommentText']}) . ';</div> And if I use double quotes as you've done it causes my page not to load while ($row = mysqli_fetch_array($query)) { //May need this later to output pictures // $imageURL = 'upload/'.rawurlencode($row["filename"]); echo " <div class='divTableRow'> <div class='divTableCell'>{$row['User']} ;</div> <div class='divTableCell'> " . nl2br({$row['CommentText']}) . ";</div> </div>
  8. Hi I am trying to use the nl2br function like this while ($row = mysqli_fetch_array($query)) { //May need this later to output pictures // $imageURL = 'upload/'.rawurlencode($row["filename"]); echo " <div class='divTableRow'> <div class='divTableCell'>{$row['User']} ;</div> <div class='divTableCell'>nl2br({$row['CommentText']});</div> </div> \n"; } However the output just looks like the attached picture. When I check in the sql db I can see the line breaks when doing a select * from Table ;
  9. Figured it out! Just had to use Intval to cast it $number = intval($_GET['id']) ;
  10. SOLVED: I'm having trouble with an SQL query via php in building my Viewthread.php file So on the main page you have a list of the Threads and the link I created is like the below <h2><a href='viewthread.php?id='{$row['id']}'> {$row['Title']} </a></h2> Post {$row['id']}<br> If I set the query to an ID that exists the page loads fine $query = mysqli_query($conn, "SELECT * FROM Threads where id='156'") however if I set the id to the GET command the page doesn't load (which should've got the id) $query = mysqli_query($conn, "SELECT * FROM Th
  11. Hi So my thumbnail upload.php file is now working. However I'd like to understand why my code isn't being run here. //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail where filename = '$Thumbnail'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo "\nUpload thumbnail if statement" ; } It doesn't echo out the echo statement so it's not hitting the if statement? My full upload.php file is below Initially I tried to update the Thumbnail into
  12. OK I added some error checking $output=null; $retval=null; exec("convert $targetFilePathArg -resize 300x200 testresize.jpg",$output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; which returns REturned with status 1 and output: The file test.jpg has been uploaded successfully. status 1 would be an error no? I also then went to create a php file with just this in <?php exec("convert arrow.png -resize 300x200 ./testresize.jpg",$output, $retval); ?> Then run this at terminal and
×
×
  • 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.