
3raser
Members-
Posts
815 -
Joined
-
Last visited
Everything posted by 3raser
-
I still need more information, sorry, it's late here and I may be reading things wrong, hah! My question is, what do you want the values of customer_id and product_id to be? If product_id is already set VIA post, you would insert it normally like everything else. Anyways, for customer_id, how would you manage to make that specially for that user? You could do it via IP, but it's not recommended. Do you have register & login system?
-
Does your code look like this? <?php session_start(); $_SESSION['ID']=$_GET['ID']; // id from previous page $ID=session_id(); ?> <iframe src="iframepage.php?ID=<?php echo $ID; ?>" style="width:680px; height:200px;" noresize="noresize" frameborder="0" border="0" scrolling="Yes" allowtransparency="true" /> </iframe> Or is the code you posted the actual code? If so, you need to start and end the PHP tags. And put the iframe tag outside the PHP tags.
-
I'm a bit confused on what your asking. Are you asking if people can submit their own data to the database manually?
-
I'm not exactly familiar with that type of upload script, but this might work: <?php if($HTTP_POST_FILES['ufile']['type'] != "image/gif" || $HTTP_POST_FILES['ufile']['type'] != "image/jpg") { echo "You've tried to upload a disallowed file type."; } else { echo "succes"; } ?>
-
Change: echo "<b>IP Address= $ip</b> "; echo "$ipDetail['country']"; to echo "<b>IP Address= $ip</b> "; echo $ipDetail['country'];
-
When I submit the form, it goes to index.php, which is the correct path.
-
Sorry, your question was a bit confusing there. <?php $query2 = "SELECT * FROM psychofarm_gen WHERE `id`!=".$randomNumber; $result2 = mysql_query($query2); if(!$i) $i = 0; while($row = mysql_fetch_array($result2)) { $i++; $wrong_answer[$i] = $row['name']; } ?> And to display the wrong_answer, say, with the id 2 <?php echo $wrong_answer[2]; ?>
-
Not sure if this is what you mean. <?php $query2 = "SELECT * FROM psychofarm_gen WHERE `id`!=".$randomNumber; $result2 = mysql_query($query2); //displays all wrong answers while($row = mysql_fetch_array($result2)) { echo $row['name']; } ?>
-
You may see a lot of things wrong with the code below, but please bring it to my attention! I'm trying to advance my knowledge on OOP, but I'm trying my best to get the basics down. The below code, after selecting the two characters to fight, the page returns nothing, just blank. I'm pretty sure the error lyes within class_li.php, but I'm not exactly sure. Script is attached. [attachment deleted by admin]
-
This returns 0 for all ranks. And what is the point of the !isset if statement? Tried this: //amount of sites $amount = mysql_num_rows(mysql_query("SELECT * FROM sites")); if($amount > 0) { //amount per page $p_page = 13; //track page $start = $_GET['page']; //max_pages $max_pages = $amount / $p_page; $offset = ($_GET['page'] - 1) * $p_page; if(!isset($_GET['page']) || $_GET['page'] < 1) $_GET['page'] = 1; //set default if(!$start) $start = 0; //new query $query = mysql_query("SELECT id,title,description,votes,date,outl,site_url FROM sites ORDER BY votes DESC LIMIT $start, $p_page"); while($fetch = mysql_fetch_assoc($query)) { $i++; $rank = $offset / $p_page + 1; echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $rank." ".$fetch['title'] ."</font></h2> <div class='entry'> <b>". $fetch['title'] ." currently has ". $fetch['votes'] ." votes. <a href='vote.php?id=". $fetch['id'] ."'>Vote now</a>.</b> <br/><br/> <p>". nl2br(stripslashes($fetch['description'])) ."</p> </div> <p class='meta'> <a href='index.php?report=". $fetch['id'] ."'>Report</a> / <a href='". $fetch['site_url'] ."'>Visit</a></p> </div> "; } //set back and forth variables $previous = $start - $p_page; $next = $start + $p_page; ?> <hr> <center> <?php if(!($start<=0)) echo "<a href='index.php?page=". $previous ."'><<</a>"; $i = 1; for($x = 0; $x < $amount; $x = $x + $p_page) { echo "<a href='index.php?page=". $x ."'> ". $i ." </a>"; $i++; } if(!($start>=$amount-$p_page)) echo "<a href='index.php?page=". $next ."'>>></a></center>"; ?> </center> <?php
-
Thanks! But it didn't seem to work. :/ - The first page was fine, but the 2nd page had numbers going into the 100s when there are only 31 sites in the database.
-
Ever since I switched over to pagination, the ranks for the sites have been off. I use to have an $i++ increment that kept the ranks, but now with pagination, it just ranks those on the current page. Is there a way to bypass this? public function grabSites() { //amount of sites $amount = mysql_num_rows(mysql_query("SELECT * FROM sites")); if($amount > 0) { //amount per page $p_page = 13; //track page $start = $_GET['page']; //max_pages $max_pages = $amount / $p_page; //set default if(!$start) $start = 0; //new query $query = mysql_query("SELECT id,title,description,votes,date,outl,site_url FROM sites ORDER BY votes DESC LIMIT $start, $p_page"); while($fetch = mysql_fetch_assoc($query)) { ++$i; $i = $i + $p_page; echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $i." ".$fetch['title'] ."</font></h2> <div class='entry'> <b>". $fetch['title'] ." currently has ". $fetch['votes'] ." votes. <a href='vote.php?id=". $fetch['id'] ."'>Vote now</a>.</b> <br/><br/> <p>". nl2br(stripslashes($fetch['description'])) ."</p> </div> <p class='meta'><a href='". $fetch['site_url'] ."'>Visit</a></p> </div> "; } //set back and forth variables $previous = $start - $p_page; $next = $start + $p_page; ?> <hr> <center> <?php if(!($start<=0)) echo "<a href='index.php?page=". $previous ."'><<</a>"; $i = 1; for($x = 0; $x < $amount; $x = $x + $p_page) { echo "<a href='index.php?page=". $x ."'> ". $i ." </a>"; $i++; } if(!($start>=$amount-$p_page)) echo "<a href='index.php?page=". $next ."'>>></a></center>"; ?> </center> <?php } else { echo " <div id='post-1' class='post'> <h2 class='title'><a href='#'>Oh NOEZ!</a></h2> <h3 class='date'>". date("M-d-Y") ."</h3> <div class='entry'> <p>There are currently no sites to display!</p> </div> <p class='meta'>View</p> </div> "; } }
-
Hah, worked, thanks.
-
Sadly, isset() didn't work. If this is what you meant: if(isset($_GET['like']) == isset($fetch['id']))
-
I'm sure you can do this in PHP, but for some reason when I view news.php - It automatically tells me I liked the post, when I haven't even clicked like yet! while($fetch = mysql_fetch_assoc($query)) { if($_GET['like'] == $fetch['id']) { $like = mysql_real_escape_string($_GET['like']); $has_liked = mysql_query("SELECT * FROM likes WHERE id = '$like' AND username = '". $_SESSION['user'] ."'"); if(mysql_num_rows($has_liked) > 0) { echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $i." ".$fetch['title'] ."</font> <h3 class='date'>". $fetch['date'] ."</h3> <div class='entry'> <p>". nl2br(stripslashes($fetch['content'])) ."</p> </div> <p class='meta'><b>You've already liked this announcement.</b></p> </div> "; } else { mysql_query("UPDATE news SET likes = likes + 1 WHERE id = '". $_GET['id'] ."'"); echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $i." ".$fetch['title'] ."</font> <h3 class='date'>". $fetch['date'] ."</h3> <div class='entry'> <p>". nl2br(stripslashes($fetch['content'])) ."</p> </div> <p class='meta'><b>You liked this announcement.</b></p> </div> "; } } else { echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $i." ".$fetch['title'] ."</font> <h3 class='date'>". $fetch['date'] ."</h3> <div class='entry'> <p>". nl2br(stripslashes($fetch['content'])) ."</p> </div> <p class='meta'><a href='news.php?like=". $fetch['id'] ."'>Like</a></p> </div> "; } }
-
Sorry, didn't see the query part. Never knew you could echo a query... Anyways, it returns the number 1.
-
The variables are correct. :/
-
I've tried mysql_error(), yet nothing is displayed, but I'm pretty sure it may be something wrong with my query. After someone inputs their new information, site title in the database is changed to 0, and description isn't updated at all.., but it's still the same data as before and isn't changed. if(!$_POST['title'] || !$_POST['description']) { echo " <table><form action='account.php' method='POST'> <input type='hidden' name='edit' value='1'> <tr><td>Site Name</td><td><input type='text' name='title' value='". $grab['title'] ."'></td></tr> <tr><td>Site Description</td><td><textarea name='description' rows='18' cols='40' maxlength='550'>". $grab['description'] ."</textarea></td></tr> <tr><td>Finished?</td><td><input type='submit' value='Update Information'></td></tr> </form></table>"; } else { $title = mysql_real_escape_string(strip_tags($_POST['title'])); $description = mysql_real_escape_string($_POST['description']); $to_censor = array("fag", "ass", "asshole", "douchebag", "dumbass"); $new = str_replace($to_censor, "****", $description); $description = strip_tags($new, "<b><i><a>"); mysql_query("UPDATE sites SET title = '$title' AND description = '$description' WHERE username = '". $_SESSION['user'] ."'") or die(mysql_error()); echo "Updated information successfully. <a href='account.php'>Back to My Account</a>"; }
-
strtotime to check if they voted within the last hour
3raser replied to 3raser's topic in PHP Coding Help
Thanks ken, I figured it out. It seems $has_voted was in the wrong place. -
strtotime to check if they voted within the last hour
3raser replied to 3raser's topic in PHP Coding Help
Thanks! And $grab['date'] is just time(). EDIT: Still no difference. -
Not sure if this is an actual error. I get this when using WAMP. Also, is the WHERE statement correct? $query = mysql_query("SELECT * FROM `book-listing` WHERE 1"); I've never seen it done that way. o.o
-
Lol thanks guys, I'll keep that as a note.
-
strtotime to check if they voted within the last hour
3raser replied to 3raser's topic in PHP Coding Help
I tried time(), but it just lets users vote as much as they want. o.O if(mysql_num_rows($has_voted) > 0) { $has_voted = mysql_query("SELECT date FROM votes WHERE ip = '". $_SERVER['REMOTE_ADDR'] ."'"); $grab = mysql_fetch_assoc($has_voted); $calc = $grab['date'] - time(); if($calc > 3600) { mysql_query("DELETE FROM votes WHERE ip = '". $_SERVER['REMOTE_ADDR'] ."'"); header("location:vote.php?id=". $id .""); } else { echo "You've voted within the last hour. Please wait ". $calc ." seconds."; } } else { if($_POST['name_vote_f'] && $_POST['id_vote_f']) { echo "You have successfully voted!"; mysql_query("INSERT INTO votes VALUES (null, '". $_SERVER['REMOTE_ADDR'] ."', '". time() ."')"); mysql_query("UPDATE sites SET votes = votes + 1 WHERE id = '$id'"); } else { $grab = mysql_fetch_assoc($query); echo "<b>Voting for ". $grab['title'] .". Are you sure?</b><br/><br/> <form action='vote.php' method='POST'> <input type='hidden' name='name_vote_f' value='". $grab['title'] ."'> <input type='hidden' name='id_vote_f' value='". $id ."'> <input type='submit' value='Yes, vote now!'> </form>"; } } -
My site allows users to vote once per hour, and it checks the next time they vote if it's been 3600 seconds (1 hour) since their last vote. But, it always returns the value 0. $grab = mysql_fetch_assoc($has_voted); $calc = strtotime($grab['date']) - strtotime(date("M-d-Y")); if($calc > 3600) { mysql_query("DELETE FROM votes WHERE ip = '". $_SERVER['REMOTE_ADDR'] ."'"); header("location:votes.php?id=". $id .""); } else { echo echo "You've voted within the last hour. Please wait ". $calc ." seconds."; }