Jump to content

Boxerman

Members
  • Posts

    275
  • Joined

  • Last visited

Everything posted by Boxerman

  1. So its calling fine now? everything works? if so please mark topic solved, and start a new topic for other questions
  2. point it towards your table, thats the script i use for news... so take the news out and add giftlistitems in replacement for it. Add your code into that
  3. yeah, as i said buddy, edit it, i.e it would be $query = "SELECT * FROM GiftList WHERE ID_GiftList='$id' ORDER BY id DESC";
  4. Take a look at this, and edit it to your liking... <?PHP $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("news", $con); /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* if id is set display the news */ if($id>0) { $query = "SELECT * FROM news WHERE id='$id' ORDER BY id DESC"; $result = mysql_query($query); $row = mysql_fetch_array($result); $title = $row['title']; $posted_by = $row['postedby']; ?><p> <b><font size="5"><?PHP echo $title; ?></font> </b><br /> <font size="2">Posted By: <?PHP echo $posted_by; ?></font> <br /> Story: <?PHP echo $row['text'] ?></p> <br> Posted At: <?php echo $row['timestamp'] ?> <br><br> <a href="/news/">Back to news listings</a> <?PHP }else{ /* create query */ $query = "SELECT * FROM news ORDER BY id DESC"; /* execute the query */ $result = mysql_query($query); while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['text'], $N); ?><p> <b><font size="5"><?PHP echo $title; ?></font></b> <br> <font size="2">Posted By: <?PHP echo $posted_by; ?></font> <br> </p><p><?PHP echo $brief; ?></p><p> <a href="news.php?id=<?PHP echo $row['id']; ?>">Read More</a></p> <?PHP } }
  5. I see, create a page, i.e product.php then get it to grab from the database the id and display what it is, so product.php?id=1 so it only displays information on id 1 etc... Make sense?
  6. Sorry, its must be my dumbness(not long finished 12 hours shift) What do you want it to do? grab data from database?
  7. Update (as i cant edit my post sorry guys) I've now got it working on uploading images to folder, but its not adding it to the database, <?php session_start(); include("header.php"); include "users/functions.php"; if (empty($_SESSION['username'])){ echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } $open=$_GET['open']; $edit=$_GET['edit']; //get data $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $user=mysql_fetch_object($query); //This is the directory where images will be saved $target = "users/images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $username=$_SESSION['username']; $title=$_POST['title']; $about=$_POST['about']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("db") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `user_pictures` VALUES ('$username', '$title', '$about', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> <html> <head> <title>upload image</title> </head> <body> <form enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST"> Title: <input type="text" name="name"><br> About: <input type="text" name = "about"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> </body> </html> <? include ("footer.php"); ?>
  8. Maybe it would help others if you posted the code you got now?
  9. Hi, Im not the best coder in the world, and i know someone will come up with a better reply, but until then, maybe take a look at http://www.w3schools.com/php/php_mysql_select.asp Maybe create var's and call them from config.php? Like i said it may not be the best but it should work.
  10. I have checked and i have put it to 777 and it still doesnt work. Thanks
  11. <?php session_start(); include("header.php"); include "users/functions.php"; if (empty($_SESSION['username'])){ echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } //get data $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $user=mysql_fetch_object($query); //This is the directory where images will be saved $target = "users/images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $username=$_SESSION['username']; $title=$_POST['title']; $about=$_POST['about']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `user_pictures` VALUES ('$username', '$title', '$about', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> <html> <head> <title>upload image</title> </head> <body> <form enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST"> Title: <input type="text" name="name"><br> About: <input type="text" name = "about"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> </body> </html> <? include ("footer.php"); ?> So sorry guys, newbie error... Thanks!
  12. <?php session_start(); include("header.php"); include "users/functions.php"; //This is the directory where images will be saved $target = "users/images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $username=$_SESSION['username']; $title=$_POST['title']; $about=$_POST['about']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `user_pictures` VALUES ('$username', '$title', '$about', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> <html> <head> <title>upload image</title> </head> <body> <form enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST"> Title: <input type="text" name="name"><br> About: <input type="text" name = "about"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> </body> </html> <? include ("footer.php"); ?> 2 things wrong. 1) It's displaying "Sorry, there was a problem uploading your file." before i even upload. 2) When uploading file, it refreshes and says added to database.. but it hasnt? can anyone see the problem.. Thanks!
  13. great its pointing me the right way! thanks pal! heres my html form: <form enctype="multipart/form-data" action="masterupload.php"> username <input type="text" name="username" size="35" /> <br /> song title <input type="text" name="song_title" size="35" /> <br /> About mix <textarea name="about" rows="4" cols="40"></textarea> <br /> Choose a file to upload: <input name="uploadedfile" type="file" /> <br /> <input type="submit" value="submit" /> </form> heres masterupload.php <?PHP $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); if ($_SERVER['REQUEST_METHOD'] == "POST") { $dir = "/users/mp3/"; $uploadfile = $dir . $_FILES['mp3_file']['name']; move_uploaded_file($_FILES['mp3_file']['tmp_name'], $uploadfile); $sql = "INSERT INTO $table (song_name, uploader, approved) VALUES ($_POST[song_name], $_POST[username], $_POST[approved],$uploadfile)"; mysql_query($sql); } ?> its not working, could someone lend a helping hand please? Thanks, B-Man
  14. Hi guys, Just trying to work my head around how i would be able to create 2 uploads; 1) Mp3 upload 2) picture upload both i want to work the same; how would i get it so when a user uploads a mp3/picture it stores the filename in the database and there username and date/time uploaded? I'm just a little confused on how i would go about it. Thanks, B-Man
  15. Thanks Tendolla, It wasnt finding the ID on where to post the updated data. Echo'ing the $sql works, and i can walk away leaving something new. Thanks!
  16. That also does not seem to work, it outputs it is successful but has not updated database. Im very confused now.
  17. Hi guys, Im making my own admin panel and i want to pull down the users profile so i can edit it i am using this to display what is currently in the database: $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form action="updateuser.php" method="post"> <input type="hidden" name="ud_id" value="<? echo $rows['email']; ?>"> <p>First Name: <input type="text" name="firstname" value="<? echo $rows['username']; ?>"><br> Last Name: <input type="text" name="lastname" value="<? echo $rows['lastname']; ?>"><br> Username: <input type="text" name="username" value="<? echo $rows['username']; ?>"><br> Age: <input type="text" name="age" value="<? echo $rows['age']; ?>"><br> User Level: <input type="text" name="user_level" value="<? echo $rows['user_level']; ?>"><br> E-mail Address: <input type="text" name="email" value="<? echo $rows['email']; ?>"><br> Bio: <textarea rows="2" name="bio" cols="21"><? echo $rows['bio']; ?></textarea><br> <br><input type="Submit" value="Update"> </p> </form> That part works, my problem is, why i click submit, it says it has been successful but the database has not been updated? can someone help Code: <?php $host=""; $user_name=""; $password=""; $db_name=""; $tbl_name=""; mysql_connect("$host", "$user_name", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="UPDATE $tbl_name SET firstname='$firstname', lastname='$lastname', username='$username', age='$age', user_level='$user_level', email='$email', bio='$bio' WHERE id='$id'"; $result=mysql_query($sql); if($result){ echo "Successful"; echo "<BR>"; echo "<a href='listusers.php'>Back to members list</a>"; } else { echo "ERROR Updating User"; } ?> Its not updating the databse can someone lead me the right way please. Thanks! J
  18. Hi guys, Im making my own login script, and i am stuck (to the point i dont have any idea) on creating a password reset, i've got the basic form, but as the password is encoded. My aim is so that when a user has forgotten their password they can click forgotten password and it will create a new password 8 letter/numbers long and insert it into there database and it will also email that password to them? Can someone please point me in the right direction? Thanks! J
  19. Hi guys, Im trying to get my members_profile.php to display the users profile.... I.e members_profile.php?boxerman will display my information. I've been at it for hours but no luck... This is what im trying to code: <?php include ("connect.php") $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); $user=mysql_fetch_assoc($user); echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; ?> It displays nothing when going to members_profile.php?boxerman Any advice as to why? Regards, B-Man
  20. Spot on lad! thanks for pointing me in the right direction, i will check them out now thanks again! Any other advice is welcome!
  21. Hey guys, I was wondering if any of you could point me towards a good simple free php login script which contains, profiles, private messaging etc.. which would be easy to add into a existing site? Anything and everything Thanks guys!
  22. Thats the one, yeah. So only selected story is displayed.
  23. When i go to story.php it displays all the news i.e: Title:123 PostedBy:123 Brief:123 Read More ---- Title:456 PostedBy:456 Brief:456 Read More ---- when i click read more on ANY of the storys it just it will just be like this: Title:123 PostedBy:123 Story: sdjaskdjaksdjaksdjkasdjkasjdkasjdkjaskdjaksjd asdohya osdih aosdh aoisdh aoisdh oaisdh oasidhasd Read More ---- Title:456 PostedBy:456 Brief:456 Read More AS you can see it still displaying other news.
  24. It displays the full story for story.php?id=90 but displays the briefs of every other story.
  25. <?php include("include/config.inc.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> <link rel="stylesheet" href="style.css" type="text/css" /> <title></title> <script language='javascript' type='text/javascript'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> </head> <body> <div id="header"></div> <div id="container"> <ul id="topmenu"> <li><a href="index.php">Home index</a></li> <li>-</li> <li><a href="contact.php">Contact Us</a></li> <li>-</li> <li><a href="report.php">Report A Error</a></li> </ul> <div id="menucontent"> <div id="links"> <div id="menu"> <h3>Menu</h3> <ul id="linksmenu"> <li><a href="index.php">Home</a></li> <li><a href="request.php">Request</a></li> <li><a href="chart.php">Chart</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Media</h3> <ul id="linksmenu"> <li><a href="music.php">Music</a></li> <li><a href="videos.php">Videos</a></li> <li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Link</h3> <ul id="linksmenu"> <li></li> <li></li> <li></li> </ul> <div id="menulast"></div> </div> </div> <div id="rechts"> <div id="rechtscontent"> <p> <?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* create query */ $query = "SELECT * FROM news ORDER BY id"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['text'], $N); ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="story.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $brief; ?></a> <?PHP if($id == $row['id']) { echo "<br>" . $row['text'] . "<hr>"; }else{ echo "<br>"; } } ?> </div> </div> </div> </div> </body> </html> There ya go dude.
×
×
  • 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.