Jump to content

Fenhopi

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

Everything posted by Fenhopi

  1. I have this in the upload file: if(!( $type=='image/jpeg' || $type=='image/png' || $type=='image/gif' )) { echo $type . " is not an acceptable format."; echo "<a href=\"form.html\">Click here</a> to try again."; die(); }
  2. Hey, I'm having some problems viewing images the I've uploaded to my mysql database. When I go to the direct link to the image (getpic.php?pid=1) I get a page full of symbols the likes of this: ����JFIF``��C !"$"$��C����"�� ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1AQaq"2�B���� #3R�br� $4� Here is the code I use to retrieve the picture: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <? if(isset($_GET['fid'])) { // connect to the database include "connect.php"; // query the server for the picture $fid = $_GET['fid']; $query = "SELECT * FROM files WHERE fid = '$fid'"; $result = mysql_query($query) or die(mysql_error()); // define results into variables $name=mysql_result($result,0,"name"); $size=mysql_result($result,0,"size"); $type=mysql_result($result,0,"type"); $content=mysql_result($result,0,"content"); // give our picture the proper headers...otherwise our page will be confused header("Content-Disposition: attachment; filename=$name"); header("Content-length: $size"); header("Content-type: $type"); echo $content; mysql_close(); }else{ die("No file ID given..."); } ?> <img src="getpicture.php?fid=1"> </body> </html> Please help me solve this issue!
  3. So, I have a website where every member can create their own blog. You can only view your friends' blogs. So what I want to do is in the page where there are links to all your friends' blogs, I want it to say "new" beside their blog when they've added a new entry, when the user clicks on the new blog I want it to mark it as read. I have no idea how to do this, seeing as I can't add a status column because there will be multiple members reading the blog. Can I make a flag thingy for each individual user? Please enlighten me with your suggestions and ideas. Thank you!
  4. Hey, I have a variable that's defined in one file, and I need to use it in another file, is there any easy way to retrieve it? I tried making a form, storing it in a label as a value, then retrieving it with the other file through $POST. This did not work unless I have a textbox, but I don't want the user to be able to edit it. Please help.
  5. No, it's not that it requires full php tags. Tested it. Good suggestion though. I'm really open for more suggestions.
  6. Well, no. It's been running with everything other than the friendship system i just added for a week. So I doubt that's it..
  7. None, I just get redirected to 000webhost´s default error page, which is the annoying part.
  8. Hi, this code worked on my local database, but not when I uploaded it to 000webhost. The tables I have set up there is exactly the same as the ones I have on my local server. Here's the code: <? include("include/session.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Opheim Online - Blog</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <!-- start header --> <div id="contmain"> <div id="main"> <div id="header"> <div id="logo"> <h1><a href="#"></a></h1> <h2><a href="" id="metamorph"></a></h2> </div> <div id="menu"> <? if($session->logged_in){ ?> <ul> <li><a href="index.php">Home</a></li> <li><a href="blog.php">Blogs</a></li> <li><a href="aboutme.php">About me</a></li> <li><? echo "[<a href=\"userinfo.php?user=$session->username\">My Account</a>]"; ?></li> <li><? echo "[<a href=\"useredit.php\">Edit Account</a>]"; ?></li> <li><? echo "[<a href=\"viewmembers.php\">View Members</a>] "; ?></li> </ul> <? } else{ ?> <ul> <li><a href="index.php">Home</a></li> </ul> <? } ?> </div> <!-- end header --> </div> <!-- start page --> <div id="page"> <!-- start content --> <div id="content"> <div class="box2"> <? if($session->logged_in){ /* Requested Username error checking */ $req_user = trim($_GET['myfriend']); if(!$req_user || strlen($req_user) == 0 || !eregi("^([0-9a-z])+$", $req_user) || !$database->usernameTaken($req_user)){ die("Username not registered"); } $req_user_info = $database->getUserInfo($req_user); $id = $_GET['myfriend']; $username = $_SESSION['username']; $sql2 = "SELECT * FROM friends2 WHERE user1='$username'"; $query2 = mysql_query($sql2); $check2 = mysql_num_rows($query2); // if you want the limit to be 50, you put 49 after < (the number minus 1) $sql = "INSERT INTO friends2 (rid, user1, user2, status) VALUES('', '$username', '$id', '0')"; mysql_query($sql); echo "Friend added"; } ?> </div></div> <!-- end content --> <!-- start sidebar two --> </div><!-- end sidebar two --> <div id="bottom" style="clear: both;"></div> </div><!-- end page --> <!-- start footer --> <div id="footer"> <p>Copyright © 2010, Opheim Online </p> </div> </div> </div> <!-- end footer --> </html> Please point it out to me if there's something you can tell is obviously wrong. Thank you!
  9. Another thing, it seems that if the first number in my database table is 1 he returns "No pending requests", instead of ignoring that and check if the next one is 0. Any ideas?
  10. The error said this now: " resource(16) of type (mysql result) Fatal error: Call to a member function fetch_object() on a non-object in /Users/Fenhopi/Sites/viewfriendreq.php on line 69"
  11. Thanks for your reply! When I did that I got this error: "Fatal error: Call to a member function fetch_object() on a non-object in viewfriendreq.php on line 66" Line 66 is the: $row = $test->fetch_object();
  12. Hi, I'm working on a friend system for my website. I'm having some problems with the view pending friend requests page. The way I have it, is if status is: 0=Friendship requested by another user, 1=already in a friendship. "status" is an INT column in my database. So I did this: $status = "SELECT status FROM friends2 WHERE user2='$username'"; $test = $database->query($status); //If user is 0 (not a friend) then display him and give options to accept or deny request if($test == '0'){ for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"user1"); echo "<a href=\"userinfo.php?user=$uname\"><h3>$uname</h3></a>has requested to become your friend "; echo "<a href=\"accept.php\">Accept</a> "; echo "<a href=\"reject.php\">Reject</a><br><br>"; } } else{ echo "No pending requests"; } } I'm not getting any errors, but it's obvious that it does not understand my if statement. Please help me find a solution. Thank you.
  13. Alright, thanks guys. I was working with a tutorial from 2004, so yeah.
  14. I have this code: <body> <?php // load config file include("dbconfig.php"); $result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect); while($myrow = mysql_fetch_assoc($result)) { echo "Title: <h1>"; echo $myrow['title']; echo "</h1><br><br> Teaser: "; echo $myrow['text1']; echo "<br><hr>"; echo "On: <i>"; echo $myrow['dtime']; echo "</i><hr align=left width=160><br><br>"; } ?> This is the code that is executed when I hit read more on my news feed. But when it select for example newsid=5 it returns with a blank page. Please help. </body> </html>
  15. Hi, I've written a code where I write a title and a message, hit submit and it gets added to my mysql database. My next page then retrieves it from the database and is supposed to put each post (title+message) in its own separate table where it just adds to the rest of the posts every time is submit something. However I can't figure out how to post each title+message separately, they just post with a line of titles, followed by a line of messages. Also, I can not figure out how to add posts to the existing posts without making a big mess. Help would be highly appreciated. Tips, hints, and maybe some example code? Thank you.
  16. Here's my code: </head> <body bgcolor="Silver"> <table> <tr><td> <? /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<ul><h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ?> <li><p class="normal">[<a href=\"userinfo.php?user=$session->username\">My Account</a>] </a></li></p>" <li>[<a href=\"useredit.php\">Edit Account</a>] </li>"; <? if($session->isAdmin()){ ?> <li>[<a href=\"admin/admin.php\">Admin Center</a>] </li>" <li>[<a href=\"process.php\">Logout</a>]</li></ul>" <? else: ?> The else function on the end is followed by the code I have for the login. If I remove the else function, just to try and run the code I get an error on a line number that doesn't exist. Please help.
  17. Hi, this is the code for my navbar: <? /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] </a>" ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } Is there anyway I can add some CSS or something to this, or set it up differently so that I can apply a CSS style to the navbar if session->logged in? Appreciate all help.
  18. Hi, can anyone help me with how I would do this? I´m trying to add some colors to my php page. But I have problems adding CSS to this code, so I figured I´d try and add an own navbar for each event. php] if($session->logged_in){ Then display navbar1 if($session->isAdmin()){ then display navbar2 } [/code]
×
×
  • 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.