Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. Okay i got the format to work but when i click next page it just shows up the same results not the next ones. <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 3; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; echo '<div id="page">'; echo '<div id="content"><br />'; echo '<h2 class="title">Tutorials By Hamish Hill</h2><br />'; $sql = "SELECT name, fullname, description, link, path FROM tutorials WHERE username='hamsterhill' $max"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo '<div class="post">'; echo '<p class="meta">' .$row["fullname"]. ' | ' .$row["name"]. '<img src="images/img08.png" alt="bullet"></p>'; echo '<div class="entry">'; echo '<p><img src=' .$row['path']. ' hspace=10 align=left>'; echo $row['description']. '</p>'; echo '</div>'; echo '</div>'; } echo "<p> Page $pagenum of $last </p>"; if ($pagenum == 1) { } else { echo " <p><a href='{$_SERVER['PHP_SELF']}?pagenum=1' class=links> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous' class=links> <-Previous</a> </p>"; } if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <p><a href='{$_SERVER['PHP_SELF']}?pagenum=$next' class=links>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last' class=links>Last ->></a></p> "; } echo '</div>'; include('footer.php'); ob_flush(); ?>
  2. do you mean you want to use the same hex color to specify background or something? if so something like PSP or GIMP tells you what the hex color is
  3. Okay here is the page in question: http://blenderteachings.000a.biz/tutorials.hamishhill.php I have the records in a database(tutorial name, username description etc). I am pulling these and displaying them but i need them to be set out like this http://blenderteachings.000a.biz/index.php But my code doesnt do it like that. Any ideas? Heres the code: <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 3; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $sql = "SELECT username, fullname, description, link FROM tutorials WHERE username='hamsterhill' $max"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { ?> <div id="page"> <div id="content"><br> <div class="post"> <p class="meta"><?php echo $row["fullname"] . ' | ' .$row["username"]; ?> <img src="images/img08.png" alt="bullet"></p> <div class="entry"> <?php echo $row['description']; echo '<br />'; } ?> </div> </div> <?php echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> </div> <?php include('footer.php'); ob_flush(); mysql_close($db); ?>
  4. Try: $sql =("UPDATE users SET points='$points' WHERE username='$user_edit'") or die(mysql_error()); $result = mysql_query($sql, $connect);
  5. that didn fix it, however i am using row in header.php which is included in every file but i thought it would be ok if i closed the connetion at the end of header.php? Is there a was around this? And yes the field type is INT
  6. I want to select values from a db table and return them but when i echo the name field it brings a result from a dif table. include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $query= "SELECT name, description, link, username, fullname FROM 'tutorials' WHERE id=1"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($res) ? <p class="meta"><?php echo $row['username']; ?>
  7. ok well i think the easiest thing to do is get rid lol, its not really an important feature as the site isnt a foru or anything like that just a tut site. Cheers anyway, but i think working round this is gonna cause more problems than i need lol.
  8. so if there is no way to delete the record when they are logged out automatically how would i change this code so they arent logged out automatically, and would that even be feasable(spelling?) ie security?
  9. I have a login system setup and i made it echo number of users online by inserting the username into a dif tble when they log in and echoing the numrows in tht table. And when they logout it is removed, however when the session times out and they are logged out automatically it doesnt delete the row so it still says there is a user online. Here is the logout code: <?php $username = $_COOKIE['ID_my_site']; $db=mysql_connect("myinfo") or die(mysql_error()); mysql_select_db("mydb") or die(mysql_error()); $past = time() - 100; setcookie(ID_my_site, gone, $past); setcookie(Key_my_site, gone, $past); $sql="DELETE FROM online WHERE username = '$username'"; header("Location: index.php"); ?>
  10. @mattyvx: yeh that did it, although i did it before reading this i cant believe i missed the fact that i wasnt even running the query lol, bit embarrising but atleast it works now. Cheers for he help guys
  11. yep and there are no errors at all
  12. Okay here is the code: if (isset ($_COOKIE['ID_my_site'])) { $username = mysql_real_escape_string($_COOKIE['ID_my_site']); $pass = mysql_real_escape_string($_COOKIE['Key_my_site']); $check = mysql_query("SELECT * FROM users WHERE username = '{$username}'")or trigger_error (mysql_error()); if (mysql_num_rows ($check) > 0) { $info = mysql_fetch_array ($check); //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } else { $uploadDir = 'uploads/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $query = ("UPDATE users SET path='$filePath' WHERE username='$username'"); echo $query; } } } } else { header("Location: login.php"); exit (0); } ob_flush(); ?> When i run it the image is uploaded to the server but the db row isnt updated. Yet when i echo the query and put that into phpmyadmin it works fine. So why doesnt it work in php? Cheers
  13. Okay i did an echo on the query and came up with this: UPDATE users SET path = "uploads/sbbody-l.gif" WHERE username = "doddsey_65" And when run in phpmyadmin it works fine and updates the row, so why doesnt it do this when i run it within the php file?
  14. <?php $to_email = "info@ideatoceo.com"; $subject = "Greetings"; $message = echo '<table width="676"><tr>Hi <td width="30" height="52"><img src="Side.gif" width="30" height="50" alt="Corner" /></td> <td width="600"><img src="Top.gif" width="600" height="50" alt="Top" /></td> <td width="30"><img src="Side.gif" width="30" height="50" alt="Corner" /> </td></tr></table>'; ?>
  15. Okay my code doesnt seem to work but i dont know why $uploadDir = 'uploads/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $query = ("UPDATE users SET path = '$filepath' WHERE username = '$username'") or die (mysql_error()); It uploads the image but not the path Username is already defined earlier in the code and my form is fine. Can anyone see why its not working?
  16. same here, i have an ai on an id table. cheers for the help people. I did think halfway through however why dont i just gointo the database and delete them, but im going to use this way anyway cos my db loads too slowly. Cheers
  17. yes, but how would i get the hyperlink to know its the user next to it that i want it to delete Eg. User: Tom [delete] User: Dick [delete] User: Harry[delete] How would i delete tom with the code i am using to display them
  18. I currently have a user managment system im working on. What i want is to have a hyperlink next to the rows that are pulled(see code below). with this button i can delete the respective row from the db therefore deleting the user. Here is the code i am using to display their details: $sql = "SELECT name, email, date FROM users"; $res = mysql_query($sql, $db); while($row = mysql_fetch_array($res, MYSQL_ASSOC)) { echo $row['name'] . ": " . $row['email'] . " -- " . $row['date']; echo "<br />"; } I know how to delete records, what i dont know how to do is to delete the record I want ie. the one next to the delete link if you know what i mean.
  19. okay all i want to do atm is see if the email gets hthrough, so additional stuff can be held back for the min, what do i need my host to do so the email does go through?
  20. Here it is: <?php $to = "myemail@hotmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?>
  21. im using a hosted server. ive checked the spam box in hotmail and it isnt there either. or do you mean it wont even go there?
  22. I have found a few scripts that show me how to do it but none of them work, i never get the email. I dont know if it matters that im trying to send the email to hotmail address but i have tried gmail aswell and it doesnt work. How would i go about this? The email is a welcome email for when they register so i dont need any forms. Cheers
  23. that one doesnt work, even though it says it has uploaded the file it hasnt. And at the bottom it says not to use the script on a public site cos its not safe or secure. plus i want the path of the uploaded image to go into the database where their login details are held so that when it pulls their other details for the my account section it also only pulls their image.
×
×
  • 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.