PHP - Problem With Comment Page :( !
Hi all i hope to find cure to my problems
here is code of comment link <a href='/blogs/?page=comment&id=".$row['id']."'>Comment</a> here is code of whole comment page http://paste.php.lv/4c30d2286cdd7334d856ce966abc618f?lang=php And here is Pictures what's is going on on website.... Here is my main issue there are 3 comment's and they all well make such mess .... and if there aren't any comment's have such issue .... Similar TutorialsCREATE TABLE posts ( postId INT(11) NOT NULL UNIQUE AUTO_INCREMENT, title VARCHAR(255) NOT NULL, author VARCHAR(24) NOT NULL, description TEXT NOT NULL, createdAt TIMESTAMP, PRIMARY KEY (postId) ); CREATE TABLE comments( commentId INT(11) NOT NULL UNIQUE AUTO_INCREMENT, comment TEXT NOT NULL, postId INT(11), userId INT(11), createdAt TIMESTAMP, PRIMARY KEY (commentId), FOREIGN KEY (userId) REFERENCES users(userId), FOREIGN KEY (postId) REFERENCES posts(postId) ); CREATE TABLE replies ( repId INT(11) NOT NULL UNIQUE AUTO_INCREMENT, reply TEXT NOT NULL, userId INT(11), commentId INT(11), createdAt TIMESTAMP, PRIMARY KEY (repId), FOREIGN KEY (userId) REFERENCES users(userId), FOREIGN KEY (commentId) REFERENCES comments(commentId) ); CREATE TABLE users ( userId INT(11) NOT NULL UNIQUE AUTO_INCREMENT, userName VARCHAR(100) NOT NULL,, email VARCHAR(100) NOT NULL, PRIMARY KEY (userId) ); how to retrive userName,comment, and createdAt from users and comments table while I have used userId as a Foreign key on the comment table if it isn't correct, correct me please Hi guyz, I am looking to create a dymanic comment box for my website where already logged in users can comment on webpages. It is quite a challenge getting to dynamically display only the comments a particular user posted on a web page. What I mean is I would like to be able to click on a page, see only the comments logged users posted on that page, and then post my own comment on that page. At the moment I created a comment box for my webpages but the issue is my posted comments on one particular page is displaying on all web pages with is comment system..This is the problem and it is very difficult to find helpful material hopefully you guyz can come to the rescue. Please guys any help or suggestions are more than welcome. Thanks Kdiamonds I am looking to add a comment area to pages that are created with data that is pulled off of a database. I am looking for something like the forums on this site, but not as complex. I was thinking about attempting to use a text file to hold the comments for each ID number that is in my database and then displaying those comments when the ID number is called. I'm not sure how I would go about making a function that would search if there was a text file for that ID number and if not to create one. I'm not even sure if this is the best way to go about it but I know if I put all the comments into a database it will get rather large rather quickly. Any pointers and good tutorials would be welcome. Sorry if it sounds as if this post is rambling, I think I need to step away from the computer for a bit. Thanks Ok. Thought I'd be able to do this myself but ran into a couple of snags. This is the template page for the image thumbnails. WHen a thumbnail is clicked it is dragged into this template. I put the code for the comments on the page but it's just not working properly. When I post comment the comment posts but the picture turns into my BAD PHOTO ID error message. Have some ideas on whats going but it's getting kind of messy. If you need to see the pages from the comment system I will post. Thanks phpeople. Where's fugix? Code: [Select] <!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>What do you know about.......</title> <style type="text/css"> #What { text-align: center; } </style> </head> <body> <div id="What"><img src="images/what.png" width="477" height="36" alt="do you know something i don't" /></div> <?php $hostname='fd.db.fdffd.d.com'; $username='d'; $password='d!'; $dbname='d'; $usertable='d'; mysql_connect('yd.com', 'yd9', 'Ad!') or die(mysql_error()); mysql_select_db("yd9") or die(mysql_error()); $id = (int)$_GET['id']; if( $id > 0 ) { $result = mysql_query("SELECT `name`, `photopath`, `state` FROM `photo` WHERE `id` = $id") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo " <img src=\"/{$row['photopath']}\" height=\"400px\" width=\"400px\" />". "<br /> "; echo $row['name']. "\n". "<br/>"; echo $row['state']. "\n"; } else { echo 'BAD PHOTO ID'; } ?> <?php $hostname='durce.com'; $username='yod9'; $password='Ad1!'; $dbname='yd'; $usertable='d'; mysql_connect('yd, 'yd9', 'Ad!') or die(mysql_error()); mysql_select_db("yd") or die(mysql_error()); $name=$_POST['name']; $comment=$_POST['comment']; $submit=$_POST['submit']; if($submit) { if($name&&$comment) { $query=mysql_query("INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')"); } else { echo "Please fill out all the fields."; } } ?> <body> <div id="comments"> <form action="image_show.php" method="POST"> <label>Name: </label><br /><input type="text" name="name" input id="name"value="<?php echo "$name" ?>" /><br /><br /> <label>Comment: </label><br /><input type="text" input id="comment"/><textarea name="comment" "cols="25" rows="7"></textarea><br /><br /><br /> <input type="submit" name="submit" value="Comment" /><br /> </form></div> <hr width="1100px" size="5px" /> </body> <?php $query=mysql_query("SELECT * FROM comment ORDER BY id DESC"); while($rows=mysql_fetch_assoc($query)) { $id=$rows['id']; $name=$rows['name']; $comment=$rows['comment']; $linkdel="<a href=\"delete.php?id=" . $rows['id'] . "\">Delete User</a>"; echo '<font color="red">Name:</font> ' . $name . '<br />' . '<br />' . '<font color="red">Comments:</font> ' . '<br />' . $comment . ' ' . ' ' . ' ' . ' ' . $linkdel . '<br />' . '<br />' . '<hr size="5px" width="500px" color="blue" />' ; } ?> </html> </body> </html> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=322815.0 I am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - Code: [Select] <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> Code: [Select] <form name="commentbox" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <textarea name="comment" cols="20" rows="2" onclick="document.commentbox.comment.value='';" onfocus="this.style.borderColor='yellow';" onblur="this.style.borderColor='blue';" />Comment...</textarea> </td></tr> $commentcheck = $_POST['comment']; if ($commentcheck == "Comment...") { die(' <META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\"> '); }else why does this not refresh if i comment "Comment..." it just dies and doesnt echo anything About a year ago I wrote a mod_rewrite in at sites htaccess file. It was to call a page that queried the database based on a unite code that was assigned to a member. If the member was assigned a code that was FL1001, the URL www.marketingteammates.com/FL1001 would bring up a page that quaried that member and displayed their database content.
In the users table of the site, it quaried the field webPageID and the information was called. It called a page webpage.php that quaried the info. The URL in the address bar still displayed www.marketingteammates.com/FL1001. Here are the lines of code in the htaccess file.
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z])([A-Za-z])([0-9]+)$ /webpage.php?webPageID=$1$2$3 [NC,L]I now have a second page completely different from the webpage.php. It is a page storeNumber.php and would query a field storeNumberID. This field could contain any kind of string such as Store#101, or mystore101, or #101 is my store. I tried using the same rewite rule just replaceing the webpage.php and variable with storeNumber.php and $storeNumberID. This doesn't work. It also leads me to wonder if there can even be two different pages in the mod_rewrite. How would it diferentiate one from the other. Thanks for any help in advance. Mike Okay... Since my last post about the website I was working on, I've figured out what I was asking. But now, I've run into another problem... Once I have a functional form on my website where a user inputs data and presses submit, how do I go about getting it to remain posted where directed? So if the user types his first and last name and presses submit, how do I get their input to remain posted on the page, much like a guestbook? I'm a newbie at this stuff, but it's a must for mine and my partner's website. Thanks again! PS... I have the code for the form all typed out and it works, it just displays the data with $echo rather than posting it permanantly. Good Afternoon everyone. I am having some problems in getting a script I found on a forum to work, I have tried contacting the original author but with no joy. Basically its a php/ajax comment system, however I am getting these errors Code: [Select] Notice: Undefined index: type in C:\wamp\www\buy2earn\viewm.php on line 93 Notice: Undefined index: type in C:\wamp\www\buy2earn\viewm.php on line 105 Here is the portion of code that I am working on, I don't understand what $_post['type'] is meant to come from? I guess its basically if the form has been submitted, but if I change the values tp 'submit' I still get the same result, just with the message submit is undefined instead! <?php $date=date("Y-m-d"); $username = $_SESSION['username']; if($_POST['type'] == "addcomment") { $username = mysql_real_escape_string($_POST['username']); $comment = mysql_real_escape_string($_POST['comment']); if($username == "" || $comment == "") { die("<p><font color='red'>Error: Please include a message.</font></p>"); } $q1 = mysql_query("INSERT INTO 'comments' ('c_id', 'm_id', 'username', 'date', 'comment') VALUES ('', '$m_id', '$username', '$date', '$comment')") or die("<p>Mysql Error: <b>".mysql_error()."</b></p>"); echo "<p><font color='green'>Comment added successfully.</font></p>"; } elseif($_POST['type'] == "getcomments") { $q1 = mysql_query("SELECT * FROM 'comments'"); $n1 = mysql_num_rows($q1); if($n1 == 0) { die("<p><font color='red'>No comments were found.</font></p>"); } echo "<table border=1>"; echo "<tr><td><b>User</b></td><td><b>Comment</b></td></tr>"; while($r1 = mysql_fetch_assoc($q1)) { $a = $r1['username']; $m = $r1['comment']; echo "<tr><td>$a</td><td>$m</td></tr>"; } echo "</table>"; } else {?> <div style="font-size: 18px;"> <p>Current Comments: </p> <div id="comments"></div> <hr /> <p>Add a comment:</p> <form action="<?php $_SERVER['PHP_SELF'];?>" method="post"> <p>Username: <input type="text" name="username" id="username" /></p> <p>Comment: <textarea name="message" cols="50" rows="10" id="message"></textarea></p> <p><input type="submit" name="submit" value="Add Comment" id="submit" /></p> </form> <div id="return"></div> </div> <?php } ?> Many Thanks for any help I have a comment form that I have created. It gets the id from the database and prints out the data that goes with that id, but what it also does is prints out the information into the form. I want a blank form so that the user can add a comment to the record. Any ideas? This the code for the form: Code: [Select] <form method="post" action="pv.php?id=<?php echo $row['ID']?>&action=<?php echo $form_action ?>"> <fieldset> <legend></legend> <p> <label for="cname">Date Of Birth</label> * <input id="cname" name="dateofbirth" class="required date" value="<?php echo $row['Date_Of_Birth']?>" /> (eg 1978.11.11) </p> <p> <label for="cgender">Gender</label> * <input type="radio" name="gender" value="Male" <?php if($row['Gender']=='male'){echo 'checked';}?>/> Male <input type="radio" name="gender" value="Female" <?php if($row['Gender']=='female'){echo 'checked';}?>/> Female </td> </p> <p> <label for="curl">Title</label> * <select name="title" id="title" class="required"> <option value="">Please Select</option> <option value="Mr" <?php if($row['Title']=='Mr'){echo 'selected';}?>>Mr</option> <option value="Ms" <?php if($row['Title']=='Ms'){echo 'selected';}?>>Ms</option> <option value="Mrs" <?php if($row['Title']=='Mrs'){echo 'selected';}?>>Mrs</option> <option value="Miss" <?php if($row['Title']=='Miss'){echo 'selected';}?>>Miss</option> <option value="Other" <?php if($row['Title']=='Other'){echo 'selected';}?>>Other</option> </select> </p> <p> <label for="ccomment">First Name</label> * <input type="text" name="firstname" value="<?php echo $row['First_Name']?>" maxlength="50" /> </p> <p> <label for="cemail">Last Name</label> * <input id="cemail" type="text" name="lastname" value="<?php echo $row['Last_Name']?>" maxlength="75" /> </p> <p> <label for="ccomment">Address 1</label>* <input type="text" name="address1" value="<?php echo $row['Address_Line_1']?>" maxlength="50" /> </p> <p> <label for="ccomment">Address 2</label> <input type="text" name="address2" value="<?php echo $row['Address_Line_2']?>" maxlength="50" /> </p> <p> <label for="ccomment">City</label>* <input type="text" name="city" value="<?php echo $row['City']?>" maxlength="50" /> </p> <p> <label for="ccomment">Postcode</label>* <input type="text" name="postcode" value="<?php echo $row['Postcode']?>" maxlength= "10" /> (eg LE5 5QE) </p> <p> <label for="ccomment">Contact No</label>* <input type="text" name="contactno" value="<?php echo $row['Contact_No']?>" maxlength= "12" /> (eg 077448825723) </p> <p> <label for="ccomment">Email</label>* <input type="text" name="email" value="<?php echo $row['Email']?>" maxlength= "40"/> (eg info@example.com) </p> <p> <label for="ccomment">Comment</label> <textarea rows="10" cols="30" name="note" maxlength= "500"><?php echo $row['Additional_Comment']?></textarea> </p> <p> <input class="submit" type="submit" value="Submit"/> </p> <p> <a href='pv.php'>Main Page</a> </p> </fieldset> This is the code for printing out the data on the page: Code: [Select] if($_GET['action']=='comment'){ $form_action = 'comment_ok'; $id=$_GET['id']; $result = mysql_query("SELECT * FROM project_data WHERE id='$id'"); $row = mysql_fetch_array($result); echo'<b>'; echo $row['Date_Of_Birth']; echo '  '; echo $row['Gender']; echo '  '; echo $row['Title']; echo '  '; echo $row['First_Name']; echo '  '; echo $row['Last_Name']; echo '  '; echo $row['Address_Line_1']; echo '  '; echo $row['Address_Line_2']; echo '  '; echo $row['City']; echo '  '; echo $row['Postcode']; echo '  '; echo $row['Contact_No']; echo '  '; echo $row['Email']; echo '  '; echo $row['Additional_Comment']; echo '</b>'; } and a snippet of the code I am using to send the id to the form: Code: [Select] echo "<td><a href='pv.php?action=edit&id=" . $row['ID']."'>Edit</a>  <a href='pv.php?action=delete_ok&id=" . $row['ID']."'>Delete</a>  <a href='pv.php?action=comment&id=" . $row['ID']."'>Comment</a></td>"; echo "</tr>"; Hi everyone, I have a like button on repeating regions that is used for keeping a record of votes on comments. People click it an it adds 1 to the votes column total. It works just fine. Problem is i only want to a allow a user one vote per comment only. can vote on other comments as well, but again, only one vote per day per comment. i wouldn't know where to start. Would i use a cookie or record an ip? switch ($_REQUEST['action']) { case 'likeit'; foreach($_REQUEST as $key=>$value){ $$key = $value; } $votes = $_GET['votes']; $total = ($votes + 1); $sql = mysql_query("UPDATE quotes SET votes = '$total' WHERE quoteid = '$quoteid'"); break; } Hi, can anyone help show me or tell me where I can find out how I can create a comment box system that will get the members userid/username and post it with the comment when it has been submitted on the page. e.g the way youtube displays comments with the username and then the comment underneath. thanks, Hi, I'm trying to improve my coding and would appreciate if someone could comment and alter my code. I dont know what would work best, named placeholders or question mark placeholders. Place the variables in a array first and then do the binding. Im looking also for solutions regarding record update using place holders. Thanks $idnrr = 1; $users = DB::getInstance()->query("SELECT * FROM users WHERE id = :id1", array(':id1' => $idnrr)); if ($users->count()) { foreach ($users->results() as $result) { echo $result->name . "<br />"; } } public function query($sql, $params) { $this->_error = false; if ($this->_query = $this->_pdo->prepare($sql)) { $x = 1; if ($this->_query->execute($params)) { $this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ); $this->_count = $this->_query->rowCount(); } else { $this->_error = true; } } return $this; } I dont no if this should even go here but here it goes. I created a blog were each blog post is veiwed on the same page in regards to the id passed to it (as standard). What i really need to do is incorporate the facebook comment box onto the page but... it only relates to the document itself rather than it's dynamic content. I've got a comment box that connects to a MySQL database. I've got this error message here when I use the PHP include function to call on this script on my main page http://www.inkzoid.com/index.php ... <?php // calling session_start() the function which starts our authentication session session_start(); // connecting to mysql server $l = mysql_connect ( "999.999.999.999" , "inkzoid" , "999) or die("Error connecting:<BR><BR>".mysql_error()); mysql_select_db( "inkzoid" ) or die("Error getting db:<BR><BR>".mysql_error()); // defining getShouts() which is our function that gets all of our shouts function getShouts() { echo '<div align="center"> <table width="150" border="0" cellspacing="0" cellpadding="0"> <tr> <td> '; $query = mysql_query("SELECT * FROM shouts ORDER BY id DESC LIMIT 10") or die(mysql_error()); while ($row = mysql_fetch_array($query) ) { $name = stripslashes($row['Name']); $contact = stripslashes($row['Contact']); $shout = stripslashes($row['Shout']); if(empty($contact)) { echo '<p><span class="author">'.$name.'</span> - <span class="shout">'.$shout.'</span></p>'; } else { echo '<p><span class="author"><a href="'.$contact.'" target="_blank">'.$name.'</a></span> - <span class="shout">'.$shout.'</span></p>'; } // if empty contact } // while row mysqlfetcharray query echo '<br><br>'; echo ' </td> </tr> <tr> <td height="10"> </td> <form name="shout" method="post" action="shout.php"> <div align="center"> <input name="name" type="text" id="name" value="Name" size="25" maxlength="10"><br> <input name="contact" type="text" id="contact" value="http://" size="25"><br> <input name="message" type="text" id="message" value="Message" size="25"><br> <input name="shout" type="submit" id="shout" value="Shout!"> </div> </form> </td> </tr> </table> </div> '; } // function getshouts // our processing if control statement if ( isset ( $_POST['shout'] ) ) { $name = addslashes($_POST['name']); $contact = addslashes($_POST['contact']); $message = $_POST['message']; if ( ( isset($name) ) && ( isset($message) ) ) { // getting smilie list $smilies = mysql_query("SELECT * FROM smilies") or die(mysql_error()); while($get = mysql_fetch_array ($smilies)) { $alt = $get['Alt']; $smilie = $get['URL']; $message = str_replace( $get['Symbol'] , '<img src="smilies/'.$smilie.'" border="0" width="15" height="15" alt="'.$alt.'">' , $message); $themessage = addslashes($message); // replacing all smilies } mysql_query("INSERT INTO shouts (Name, Contact, Shout) VALUES ( '$name' , '$contact' , '$message' )") or die(mysql_error()); $_SESSION['has_posted'] = 'yes'; header("Location: shout.php"); // if required fields aren't empty, process into database } else { echo '<script>alert("Some fields were not filled out!");</script>'; header("Location: shout.php"); // if required fields were left empty, show an error dialog } }/* else { echo '<script>alert("Please follow the form to this page.");</script>'; header("Location: shout.php"); // if they weren't even referred from the form, show error dialog and redirect } // if isset post shout /* STARTING THE MAIN SCRIPT NOW */ // starting the table //displaying the shouts getShouts(); mysql_close($l); ?> I was told that I should put ob_start(); at the top of my page and ob_end_clear(); at the end of my page, but should that code go on the shout.php file or my index.php file (index.php is where I want my comment box to go)? I was using session_start(); but I got some error messsages about headers already being sent because I had originally used the php include function at the top of index.php to include shout.php. After reading up on it I found out that the error was caused by not having session_start(); being the first line of code. So my problem was that I wanted the comment box to be somewhere other than at the top of the page. Not sure how to move it. Anyways I'm pretty confused right now and if someone could give me some advice it would be appreciated. Ok, so I want to make a comment spam filter for my site. I know the basic logic, but have yet to figure out how to write the functions. I have a database table called comments that has a column called "time", which contains a unix timestamp value of when it was posted. Basically what I want to do is this: When a user tries to post a comment, the script determines with a database query if they have posted a comment in the last 120 seconds. So basically I have to find the current time, and the time it was 120 seconds before the current time. Then I have to find any comments posted by the user that were made after the 120 second mark. My database query should then look something like this, right? Code: [Select] $query = mysql_query("SELECT * FROM comments WHERE author = ".$_SESSION['id']." AND time > '".$120secondsago"'"); Please correct me if my logic is wrong, which it very well may be, but how would I find the unix timestamp code from 120 seconds before the current time? Note that 120 seconds is just an example and also that I have not worked with dates in mysql very often. $query = mysql_query("SELECT * FROM comments WHERE author = ".$_SESSION['id']." AND time Hi guys I'm trying to modify the following script so that only registered users can post comments. Can you guys help please thanks? <?php require_once("admin_common.php"); session_start(); if(is_numeric($_REQUEST['id'])){ $imageid = $_REQUEST['id']; }else{ header("Location: http://mysite.net/"); } if($_POST['submit']){ if($_POST['username']==''){ $err = "You must log in."; }elseif($_POST['thecomment']==''){ $err = "You have to enter a comment."; }else{ $name = strip_tags($_POST['thename']); $themessage = strip_tags($_POST['thecomment']); $ezdb->get_results("INSERT INTO user_comments (id,date_added, posted_by, message, image_id) VALUE ('','".time()."','".$name."','".$themessage."','".$imageid."')"); $err = "Thank you for your comment."; } } if($err){ $err = '<span style="color:#FF0000;">'.$err.'</span>'; } /* Update table `iid_ip`. Between the dashed lines is the create statement used to create the image view count (iid_ip) table. ---------------------------------------- delimiter $$ CREATE TABLE `iid_ip` ( `iid` int(11) unsigned NOT NULL COMMENT 'Image id from where the count is the number of unique views.', `ip` varchar(15) NOT NULL COMMENT 'The ip of the visitor.', PRIMARY KEY (`iid`), KEY `ip` (`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Table for view count of image using unique ip''s.'$$ ---------------------------------------- */// Escape variables that are used in the query. $_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $_iid = mysql_real_escape_string($imageid); // Count is 0 if ip has NOT seen the images, else count is 1 $_count = $ezdb->get_var("SELECT COUNT(*) FROM `iid_ip` WHERE `iid`='$_iid' AND `ip`='$_ip'"); if (!$_count) { // Insert the unique combination of image id and visitor ip in `iid_ip`. // Method doesn't exists! $ezdb->quick_insert('iid_ip', array('iid' => $_iid, 'ip' => $_ip)); $ezdb->get_results("INSERT INTO `iid_ip` (`iid`,`ip`) VALUES ('$_iid','$_ip')"); } // Get count of image views. $_views = $ezdb->get_var("SELECT COUNT(*) FROM `iid_ip` WHERE `iid`='$_iid'"); // And format, thousands seperator is a comma, no decimals. $_views = number_format($_views, 0, '', ','); ///////////////////////////// $page->addHTMLHead($scripthead); $d[] = "<div id='imagedetails'>"; $imgs = $ezdb->get_results("Select * From image_map Where id='".$imageid."'"); $name = $ezdb->get_var("Select name From `".$imgs[0]->obj_type."s` WHERE id ='".$imgs[0]->obj_id."'"); if($imgs[0]->obj_type=='comment') $pg='comm'; if($imgs[0]->obj_type=='image') $pg='img'; $d[] = "<a href='imagepage.php?".$pg."=".$imgs[0]->obj_id."' style='text-decoration:none;'>«".ucfirst($imgs[0]->obj_type)."s - $name</a><br /><br />"; // DEFINE SIMPLE GRID if ($imgs[0]->user_id != 0) { $theuser = $ezdb->get_var("SELECT username FROM users WHERE user_id='".$imgs[0]->user_id."'"); } else { $theuser = $imgs[0]->creator_name; } $d[]="<div style='float:left; width:450px; text-align:center;'> <a href='contact.php'><img src='assets/images/leftAdjpg'></a> <br /> <div style='font-size:12px; margin-top:30px; margin-left:5px;'> ".'Html Code: Use for websites, blogs, profiles and myspace.<br /><input name="textfield3" type="text" class="imagedetails_links" id="textfield3" onclick="this.select();this.focus()" value="<a href="http://www.mysite.net/imagedetails.php?id='.$imageid.'"><img src="http://www.mysite.net/uploads/'.$imgs[0]->link.'" border="0" alt=" " /></a><br /><a href="http://www.mysite.net"></a>" size="70" /> <br /> For posting in forums use this: <input name="textfield6" type="text" class="imagedetails_links" id="textfield6" onclick="this.select();this.focus()" value="[url=http://www.mysite.net][img]http://www.mysite.net/uploads/'.$imgs[0]->link.'[/img][/url]" size="70" /> <br /> </div> <div style="float:left; width:450px; margin-left:34px; margin-top:5px;"><table width="100" border="0"> <tr> <td class="widgets"><a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></td> <td class="widgets"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmysite.net%2F&layout=box_count&show_faces=false&width=450&action=like&font=arial&colorscheme=light&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:65px;" allowTransparency="true"></iframe></td> </tr> </table></div> '; if(ereg('.gif',$imgs[0]->link)){ $thelarge ="<img src='uploads/".$imgs[0]->link."' alt='".$imgs[0]->name."' style='border:0px solid #cccccc;' />"; }else{ $thelarge ="<img src='imageresize.php?imagepath=uploads/".$imgs[0]->link."&width=500&height=500' alt='".$imgs[0]->name."' style='border:0px solid #cccccc;' />"; } $d[]=" </div> <div style='float:left; margin-left:10px;'> <p style='padding:0; margin:0; margin-right:20px; text-align:center; font-size:14px;'><a href='force.php?path=uploads/".$imgs[0]->link."'>Click to Download Image</a></p><br /> ".$thelarge." <div style='overflow:auto; clear:both'> <div style='float:left; text-align: left;'> Image: <span style='color:#FFFFFF;'>{$imgs[0]->name}</span><br /> <span style='color:#ffffff; font-size:13px;'>Posted on: ".date('m-d-Y',$imgs[0]->date_added)." by ".ucfirst($theuser)."</span> </div> <div style='float:right'> <!-- Insert unique view count --> <span style='color:#ffffff; font-size:13px;'>Views: $_views</span> </div> </div> ".' </div> <div style="clear:both;"></div> <div style="margin:0 auto;"><br />'.$err.' <form action="'.$_SERVER['PHP_SELF'].'" method="post" style="margin:0 auto; width:400px; color:#ffffff; font-size:11px; text-align:left;"> <div style="margin-bottom:5px;">Leave a comment:</div><input type="hidden" name="id" value="'.$imageid.'" /> Your name: <input type="text" name="thename" style="width:250px;" class="inputfields" value="'.$_SESSION['username'].'"/><br /> Your comment:<br /><textarea name="thecomment" style="width:400px; height:70px;" cols="50" rows="4" class="textareas" ></textarea><br /> <input type="submit" name="submit" value="Post Comment" style="float:right;"/> </form> </div>'; $getallcomments = $ezdb->get_results("SELECT * FROM user_comments WHERE image_id='".$imageid."' ORDER BY date_added DESC"); $uclist = '<div style="margin:0 auto; width:410px; padding:5px; border:0px solid #cccccc; margin-top:40px;">'; if(sizeof($getallcomments)>0){ foreach ($getallcomments as $ac){ $uclist .='<div style="border-bottom:2px solid #333333; width:400px; color:#ffffff; font-size:12px; margin:0 auto; text-align:left;"><br />Posted on:<span style="color:#000000;"> '.date('m-d-Y',$ac->date_added).' at '.date('H:i a',$ac->date_added).'.</span><br />Posted by:<span style="color:#000000;"> '.strip_tags($ac->posted_by).'</span><br /><span style="color:#ffffff;">'.strip_tags($ac->message).'</span></div>'; } }else{ $uclist.='<div style="border-bottom:2px solid #ffffff; width:400px; color:#ffffff; font-size:12px; margin:0 auto; text-align:center;">Be the first to leave a comment!</div>'; } $uclist.="</div><div style='clear:both;'></div><br /><br />"; $d[] = $uclist."</div>"; $page->add($d); echo $page->render(); ?> |