Jump to content

Hacym

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Hacym's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You realize that you resurrected a topic from 2008, right?
  2. When I was just starting out I just picked a small project and googled the different parts of how to do it. Learning by doing is always the best way, I think.
  3. Nevermind. I got it to work. Solved.
  4. Edit: I changed this: unlink($_GET['pasteid'].'.txt'); and am now getting a blank file.
  5. Hello. I am currently using an iframe to deliver my page, download.php, without changing my current page. The download.php page current looks like this: <?php require('config.php'); $contentlookup = $mysqli->prepare("SELECT content FROM publicpastes WHERE pasteid=?"); $contentlookup->bind_param("s", $_GET['pasteid']); $contentlookup->bind_result($contenttowrite); $contentlookup->execute(); $contentlookup->fetch(); $filename = $_GET['pasteid'].'.txt'; $filehandle = fopen($filename, 'w'); fwrite($filehandle, $contenttowrite); fclose($filehandle); $file = $_GET['pasteid'].'.txt'; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$file); readfile($file); unlink($pasteid.'.txt'); ?> So basically, I want it to create the file [pasteid].txt with the content from $contenttowrite. When downloading and opening the .txt file, though, I am getting this error: Any ideas as to what I am doing wrong?
  6. Hacym

    Mod_Rewrite Issue

    Thank you! It works! Just one more thing, though. I can still go to the actual link and it doesn't change it. Is there a way to make it do that? Also, yes, the pasteids will only contain letters and numbers. I'm not exactly sure how you would change that though, as I have never done anything like this :X
  7. Hacym

    Mod_Rewrite Issue

    Hello, I am trying to shorten my URLs for a pastebin-like project I am working on. Currently in my htaccess file, I have this: Options +FollowSymlinks RewriteEngine On RewriteRule ^([^/]*)$ /paste.php?pasteid=$1 [NC] I am trying to shorten mydomain.com/paste.php?pasteid=pasteid to just mydomain.com/pasteid. However, with this setup, I am getting an internal server error across the entire domain. I have looked at the logs I have avaliable to me, and cannot find anything referincing this... Any ideas?
  8. I am having a stupid issue with the following code, and I have tried to get it to work in several ways to no avail: if (isset($_POST['catcreate'])) { $catname = $_POST['catname']; $catcheck = $mysqli->prepare("SELECT * FROM categories WHERE name=? LIMIT 1"); $catcheck->bind_param("s", $catname); $catcheck->execute(); $catcheck->store_result(); $catnum = $catcheck->num_rows; $catcheck->close(); if ($catnum > 0) { echo "<div style=\"position:absolute; top:70px; left:300px;\"> Category already exists! </div>"; } else { $catadd = $mysqli->prepare("INSERT INTO categories (name) values (?)"); $catadd->bind_param("s", $catname); $catadd->execute(); $catadd->close(); echo "<div style=\"position:absolute; top:70px; left:300px;\"> Category added. </div>"; } } if (isset($_POST['catdelete'])) { $catname = $_POST['catdropdown']; $catdelete = $mysqli->prepare("DELETE FROM categories WHERE name=?"); $catdelete->bind_param("s", $catname); $catdelete->execute(); $catreset = $mysqli->prepare("UPDATE articles SET category='Uncategorized' WHERE category=?"); $catreset->bind_param("s", $catname); $catreset->execute; echo "<div style=\"position:absolute; top:70px; left:300px;\">Category deleted!</div>"; } } } It successfully deletes the category, but it doesn't reset the categories in the articles table. My var_dump says this: object(mysqli_stmt)#8 (9) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(1) ["field_count"]=> int(0) ["errno"]=> int(0) ["error"]=> string(0) "" ["sqlstate"]=> string(5) "00000" ["id"]=> int(7) } The SQL statement works in PHPMyAdmin. I'm sure it's a stupid, easy thing I am missing, but I've tried several things and nothing seems to work.
  9. I have one database with "articles," "categories," and "users" as tables.
  10. I fixed the syntax of the UPDATE and it worked. Thank you for the help. What do you mean? How else can I list info about categories?
  11. Hello, I'm getting Fatal error: Call to a member function bind_param() on a non-object on the following code: if ($_GET['link'] == "create") { if(!isset($_GET['id'])) { echo "<div style=\"position:absolute; top:20px; left:300px;\">"; echo "<form method=\"post\" action=\"index.php?link=create\">"; date_default_timezone_set('America/New_York'); $time = date('g:i A'); $date = date('F j, Y'); echo "Article title: <br />"; echo "<input type=\"text\" name=\"title\" value=\"Article Title\" onblur=\"if (this.value == '') {this.value = 'Article Title';}\" onfocus=\"if (this.value == 'Article Title') {this.value = '';}\"><br />"; echo "Posted at <input type=\"text\" name=\"time\" value=\"$time\"> on <input type=\"text\" name =\"date\" value=\"$date\"> by $username <br />"; echo "Content:<br />"; echo "<textarea name=\"content\" rows=30 cols=80></textarea> <br />"; echo "Publish <input type=\"radio\" name=\"publish\" value=\"1\" checked> now or <input type=\"radio\" name=\"publish\" value=\"0\"> later in the category named "; $mysqli->select_db("categories"); $cats = $mysqli->query("SELECT name FROM categories"); echo "<select name=\"catdropdown\" value=''>"; while ($catdropdown = mysqli_fetch_assoc($cats)) { echo '<option value="'.$catdropdown['name'].'">' . $catdropdown['name'] . '</option>'; } echo "</select>"; echo "<input type=\"hidden\" name=\"addarticle\"> <br />"; echo "<input type=\"submit\" value=\"Add Article\">"; echo "</form>"; echo "</div>"; } if (isset ($_POST['addarticle'])) { $title = $_POST['title']; $time = $_POST['time']; $date = $_POST['date']; $content = $_POST['content']; $publish = $_POST['publish']; $category = $_POST['catdropdown']; $mysqli->select_db("articles"); $articleadd = $mysqli->prepare("INSERT INTO articles (title, author, time, date, content, published, category) values (?, ?, ?, ?, ?, ?, ?)"); $articleadd->bind_param("sssssis", $title, $username, $time, $date, $content, $publish, $category); $articleadd->execute(); $added = "1"; $articleadd->close(); echo "<div style=\"position:relative; top:640px; left:280px;\">"; echo "Article has been added!"; if ($publish == 0) { echo "Remember to come back and set this to published when you're ready!"; } echo "</div>"; } if(isset($_GET['id'])) { $id = $_GET['id']; $mysqli->select_db("articles"); $query = "SELECT * FROM `articles` WHERE id=$id"; if($articleedit = $mysqli->query($query)) while ($articleeditinfo = $articleedit->fetch_assoc()) { echo "<div style=\"position:absolute; top:20px; left:300px;\">"; echo "<form method=\"post\" action=\"index.php?link=create&id=".$id."\">"; date_default_timezone_set('America/New_York'); $time = date('g:i A'); $date = date('F j, Y'); echo "Article title: <br />"; echo "<input type=\"text\" name=\"title\" value=\"".$articleeditinfo['title']."\"> <br />"; echo "Posted at <input type=\"text\" name=\"time\" value=\"".$articleeditinfo['time']."\"> on <input type=\"text\" name =\"date\" value=\"".$articleeditinfo['date']."\"> by" .$articleeditinfo['username']. "<br />"; echo "Content:<br />"; echo "<textarea name=\"content\" rows=30 cols=80>".$articleeditinfo['content']."</textarea> <br />"; echo "Publish"; if ($articleeditinfo['published'] == 1) { echo "<input type=\"radio\" name=\"publish\" value=\"1\" checked> now or <input type=\"radio\" name=\"publish\" value=\"0\"> later in the category named "; } else { echo "<input type=\"radio\" name=\"publish\" value=\"1\"> now or <input type=\"radio\" name=\"publish\" value=\"0\" checked> later in the category named "; } $mysqli->select_db("categories"); $cats = $mysqli->query("SELECT name FROM categories"); echo "<select name=\"catdropdown\" value=''>"; while ($catdropdown = mysqli_fetch_assoc($cats)) { echo '<option value="'.$catdropdown['name'].'">' . $catdropdown['name'] . '</option>'; } echo "</select>"; echo "<input type=\"hidden\" name=\"updatearticle\"> <br />"; echo "<input type=\"submit\" value=\"Update Article\">"; echo "</form>"; echo "</div>"; } if(isset($_POST['updatearticle'])) { $title = $_POST['title']; $time = $_POST['time']; $date = $_POST['date']; $content = $_POST['content']; $publish = $_POST['publish']; $category = $_POST['catdropdown']; $mysqli->select_db("articles"); $articleupdate = $mysqli->prepare("UPDATE articles (title, author, time, date, content, published, category) values (?, ?, ?, ?, ?, ?, ?)"); $articleupdate->bind_param("sssssis", $title, $username, $time, $date, $content, $publish, $category); $articleupdate->execute(); $added = "1"; $articleupdate->close(); echo "<div style=\"position:relative; top:640px; left:280px;\">"; echo "Article has been updated!"; if ($publish == 0) { echo "Remember to come back and set this to published when you're ready!"; } echo "</div>"; } } } This specific error is happening on the update of the article, so with $articleupdate. I'm fiddled with everything I can think of and cannot see where the error is occurring.
×
×
  • 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.