Jump to content

J-C

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

J-C's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Is it supposed to be in the same file? because the form is in index.php and the upload script is in upload.php, this is the form: <form action="upload.php" method="POST" enctype="multipart/form-data" name="upform" onSubmit="return No_file();"> <div class="input"> Image to upload: <br /> <input type="file" name="upload" /> <br /> </div> <center> <input type=submit name=Submit value="Upload Image" /> </center> </form>
  2. Ok my main problem is that When I refresh a page ( upload.php ) it uploads the file even if the form has not been submitted through the upload page ( index.php ), so essentially what I want is that when I refresh the page where I uploaded the file, instead of re-uploading to just keep the last uploaded file instead. Would this be achieved through sessions? if so can anyone help me please, because is really annoying that it just keeps re-uploading when I press refresh.
  3. damn could not edit post... use empty it works best...
  4. I KNOW THIS IS GRAVE DIGGING, but I was browsing through Google for some help and I decided to help the poster, Again sorry for grave digging. What you want to do is use isset(), or check if the $_POST/$_GET == 'NULL', again sorry for grave digging, I'm probably going to get flamed...
  5. J-C

    Guestbook

    After going tru the whole code one more time I finally found out what it was, thanks to you catfish i took a look at the portion you told me and figured it out, I was like wtf is $r if I have not declared it anywhere, and then i noticed that $r was incomplete it was supposed to be $rows xD so here it is $num_of_rows = $r[0]; that line should read $num_of_rows = $rows[0]; xD thanks catfish [ SOLVED ]
  6. J-C

    Guestbook

    But you made rows =16; because that is how many rows they are on that table, so if there are more rows it won't show them it would just stop at row 16... and i want to show new entered rows, any one else might know how to fix this?
  7. J-C

    Guestbook

    what the hell!!!! i see it working fine in your server!!!!!! how come in mine it just stays in the same page like here. http://74.170.18.102/gb maybe is something in my tables here: THIS is inside my while loop <center><table class=gb_table1 style="border-collapse:collapse; border:solid 1px #999999;" > <tr> <td style=> <div class=gbdiv > <table style="border-collapse:collapse; "> <tr> <td style="background:#202020; color:white; font-size:11px; font-weight:bold;" align=left> Date</td> <td style="background:#202020; color:white; font-size:11px; font-weight:bold;" align=left> : </td> <td style="background:#202020; color:#cccccc; font-size:11px; font-weight:100;padding-left:10px;"> <?php echo $rows['datetime']; ?> </td> </tr> <td style="background:#202020; color:white; font-size:11px; font-weight:bold;" align=left> Name</td> <td style="background:#202020; color:white; font-size:11px; font-weight:bold;" align=left> : </td> <td style="background:#202020; color:green; font-size:13px; font-weight:100;padding-left:10px;"> <?php echo $rows['name']; ?> </td></tr> <tr> <td style="background:#202020; color:white; font-size:11px; font-weight:bold;" align=left> Number </td> <td style="background:#202020; color:white; font-size:11px; font-weight:bold;" align=left> : </td> <td style="background:#202020; color:red; font-size:11px; font-weight:100;padding-left:10px;"> <?php echo $rows['id']; ?> </td></tr> </table> <tr><td class="comment" style="background:#333333; padding:5px; font-size:14px; color:white; " > <?php echo $rows['comment']; ?> </td></tr> </div> </td> </tr> </td> </tr> </table > </center>
  8. J-C

    Guestbook

    <?php $host="localhost"; $username=""; $password=""; $db_name="guestbook"; $tbl_name="gb"; // Connect to server and select database. $conn = mysql_connect("$host", "$username", "$password")or die("cannot connect to the server "); $select_db = mysql_select_db("$db_name",$conn)or die("cannot select the Data Base"); $sql="SELECT COUNT(*) FROM $tbl_name"; $result=mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $rows = mysql_fetch_row($result); $num_of_rows = $r[0]; $rowsperpage = 2; $totalpages = ceil($num_of_rows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT name, datetime, email, comment, id, comment FROM $tbl_name LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); //while ($list = mysql_fetch_assoc($result)) { while($rows=mysql_fetch_assoc($result)){ ?> DISPLAY ROWS HERE!!!! <?php } // end while /****** build the pagination links ******/ // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <center><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a></center> "; } // end if // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo "<center> <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> </center>"; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo "<center><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'> <font color=#6d80f6> ></font></a> "; // echo forward link for last page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'> <font color=red> >> </font></a> </center><br>"; } // end if /****** end build pagination links ******/ mysql_close(); //close database ?> Well i posted in the other thread but it says solved so i guess people won't look there, Like i said in the other thread this works just fine except when i click next page it just shows the main page the first one... I don't know what I did wrong
  9. J-C

    Guestbook

    OK so i followed the tutorial and everything works fine except for one thing... when ever i click next to go to next page it doesn't go to it, it goes to it on the browser but it still displays the same page i was currently at. <?php $host="localhost"; $username=""; $password=""; $db_name="guestbook"; $tbl_name="gb"; // Connect to server and select database. $conn = mysql_connect("$host", "$username", "$password")or die("cannot connect to the server "); $select_db = mysql_select_db("$db_name",$conn)or die("cannot select the Data Base"); $sql="SELECT COUNT(*) FROM $tbl_name"; $result=mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $rows = mysql_fetch_row($result); $num_of_rows = $r[0]; $rowsperpage = 2; $totalpages = ceil($num_of_rows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT name, datetime, email, comment, id, comment FROM $tbl_name LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); //while ($list = mysql_fetch_assoc($result)) { while($rows=mysql_fetch_assoc($result)){ ?> DISPLAY ROWS HERE!!!! <?php } // end while /****** build the pagination links ******/ // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <center><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a></center> "; } // end if // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo "<center> <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> </center>"; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo "<center><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'> <font color=#6d80f6> ></font></a> "; // echo forward link for last page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'> <font color=red> >> </font></a> </center><br>"; } // end if /****** end build pagination links ******/ mysql_close(); //close database ?>
  10. did you know you can just enable MYSQL from the xampp control panel (executable) and also run as svc ( service mode ) it works for me.
  11. J-C

    Guestbook

    LOL!! I can't believe it was right under my nose and it starts with some lil jokes that make a me lol a lil, anyways THANK YOU !
  12. J-C

    Guestbook

    EXACTLY. I have tried looking for tutorial and man no luck, I'm guessing it has to search mysql and some other stuff, if you can point me to a tutorial to achieve something similar that'd be great
  13. OH lol well you can do as suggested above or you can do this echo ' <br /> '; lol i know is really gay but it works xD
  14. LOL i actually didn't think he wanted to output an ACTUAL "<br />" xD i guess that would make more sense why he can't get it working
  15. J-C

    Guestbook

    Well I have finally coded a simple guest book for my site, didn't take long is pretty simple I haven't even added bb codes or smiles etc, but I want to know how to make a next page after 10 entries have been made in the database. For example 10 people signed my guest book I want to automatically generate another page for 10 more entries because displaying all entries would make a page load slow. I hope some one understood what i meant
×
×
  • 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.