Jump to content

twistisking

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    twistisking
  • Website URL
    http://www.twistisking.com

Profile Information

  • Gender
    Not Telling

twistisking's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I could still use some help on this if anyone has any opinions
  2. Okay I have been convinced! thank you all for the help!
  3. You can upload the Image's Binary data into Database. But its not fair and also it will increase your work load . what you need to do is just to insert the location of that Image in MySQL Database and then Use that. Thanks for the advice but all i want to do is upload the image's binary data. I already created a script the reverts the binary data back to a normal image. I can upload the binary data using phpmyadmin but for security reason of course I don't wana everyone being able to access that. Also I dont want people just inserting images on others servers, just incase that server deletes their image. Just too many problems i could run into. Anyone else have any advice to get all the image data into mysql?
  4. I thought this code was perfect but unfortunately, every time I attempt to upload an image, it will only upload 1 kb of data. Can anyone tell me what Im doing wrong? <?php $con = mysql_connect("host","login","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Database", $con); function getimage($file){ $takeFile = fopen($file, "r"); $file = fread($takeFile, filesize($file)); fclose($takeFile); return $file; } function getfileType( $name ){ $name = explode(".", $name); $name = array_reverse($name); $name = strtolower($name[0]); return $name; } $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); $allowedImageTypes = array("jpg"); if(empty($_FILES['image']['tmp_name'])){ die("File not uploaded"); } else { $fileType = $_FILES['image']['name']; if(in_array(getfileType($fileType), $allowedImageTypes)){ $fileContent = getimage($_FILES['imgfile']['tmp_name']); $sql="INSERT INTO post (poster, poster2, title, category, tagline, thearticle, image) VALUES ('$_POST[poster]','$_POST[poster2]','$_POST[title]','$_POST[category]','$_POST[tagline]','$_POST[thearticle]','$content ')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } if(mysql_affected_rows() > 0){ die("Image inserted successfully"); } else { die("Image can not be inserted check your submission"); } mysql_close($con); } else { die("This is not a valid image type"); } } ?>
  5. So me and a friend have been working on this comment page script and I got ever thing work except for one portion. After a comment is left on the page and the page reloads, I get an error. I have been trying to fix it but I haven't had any luck. If anyone could help I would very much appreciate it. I added some guidelines incase anyone wants to use this script as well. Here is the code we created: <? if (isset($_REQUEST["txtName"]) && isset($_REQUEST["txtComments"])) { $name = addslashes($_REQUEST["txtName"]); // make quotes, apostrophes, etc safe for the DB query // if they put in an e-mail address, store it in the DB, otherwise put in a blank string if (isset($_REQUEST["txtEmail"])) { $email = addslashes($_REQUEST["txtEmail"]); // make quotes, apostrophes, etc safe for the DB query } else { $email = ""; } $comment = strip_tags($_REQUEST["txtComments"],"<b><i>"); // remove any HTML besides bold and italic tags $comment = addslashes($comment); // make quotes, apostrophes, etc safe for the DB query $comment = str_replace("\n","<br>\n",$comment); // turn line breaks into HTML line breaks $id = $_REQUEST["id"]; if (!is_numeric($id)) { echo "The article specified does not exist!"; } else { @require_once("database.php"); $sql = "INSERT INTO comments (article,name,email,comment) VALUES ('$id','$name','$email','$comment')"; mysql_query($sql); if (mysql_error()) { echo "There was an error storing your comment in the database!"; } } } if (!isset($_REQUEST["id"])) { echo "There was an error displaying this page."; exit(); } if ($_REQUEST["id"] == "" || !is_numeric($_REQUEST["id"])) { echo "There was an error displaying this page."; exit(); } define("ARTICLE_ID",$_REQUEST["id"]); @require_once("../posttest.php"); @require_once("database.php"); $sql = "SELECT * FROM comments WHERE article='" . $_REQUEST["id"] . "' ORDER BY datetime DESC"; $result = mysql_query($sql); if (mysql_errno()) { echo "<div class='comment'>There was an error retrieving the comments from the database: </div>" . mysql_error(); } else { if (mysql_num_rows($result) == 0) { echo "<div class='comment'>There are currently no comments for this article.</div>"; } $x = 0; while ($data = mysql_fetch_assoc($result)) { if ($x == 0) { echo "<div class='comment_top'>\n"; $x = 1; } else { echo "<div class='comment'>\n"; } if ($data['email'] != "") { $link = "<a href='mailto:".stripslashes($data['email'])."' class='name'>".stripslashes($data['name'])."</a>"; } else { $link = "<span class='name'>".stripslashes($data['name'])."</span>"; } echo $link." <span class='cdate'>".$data['datetime']."</span><br><br>\n"; echo "<div style='text-align:left'>"; echo stripslashes($data['comment']); echo "</div>\n</div>\n"; } } ?>
  6. If it helps... here is my link http://www.twistisking.com
  7. I want to set my website up for easier updating and what not. Basically I have set my pages up in PHP as header, footer and Middle. Middle is only the post's that I post daily. I want to set up a script that will grab each post from a database i guess and post them on my middle page. Pretty simple right? Also in the script I only want to have 10 post or a vairble number listed at a time. A bunch of people referred me to some cms sites but I didn't really like them too much. I used word press and PostNuke and didn't really find what I was looking for. If anyone can help it would be very much appreciated and I'll give you BIG PLUG on my site. I know it's still under massive construction but I'll put a permalink on my site if you can help. Sorry but im very new to php.
×
×
  • 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.