Jump to content

benji87

Members
  • Posts

    136
  • Joined

  • Last visited

    Never

Everything posted by benji87

  1. Works the same as my original code it just adds the result to the previous one contained in the database so basicly its just adding up the differences and not working out the difference between the two total numbers of scored and against. Maybe i am going about this the wrong way??
  2. Nope it really dont like that....
  3. Yer thats right i want it to be worked out for all games. It didnt work there is a problem with the syntax around ($scored - $aganist) any ideas?? Here is my query: <?php $sql = mysql_query("UPDATE ssrfc_league SET points = points + '$points', $result = '$result' + 1, played = played + 1, scored = scored + '$scored', against = against + '$against', difference = $difference + ($scored - $against) WHERE team='$team'") or die (mysql_error()); ?> Cheers
  4. Hey all im currently working on a league table for a rugby club. It all works fine apart from one bit i cant work out. What i need to do is work out the trys scored difference. So the number between what they have scored and what they have conceeded. Now ive never been good at maths and im guessing there is just a simple formula for it to work but i just cant work it out! The user inputs the score of the game for each team with the score for and against for that team this is what i came up with to input into the database using the update function. difference = difference + scored - against This works correctly the first time but the second time you do it, it just adds the next difference onto the previous which is obviously wrong coz i want it to show the try difference from all games :-\ Anybody have an answer? Cheers
  5. Is that meant to be can or cant? If you can how is it possible?
  6. Hi all im working on a script in php but what im wanting to do is enable some text boxes using javascript based on the user ticking a tick box. So therefore preventing them filling in values into 2 text boxes without one being ticked......thanks
  7. Hey all could someone please tell me why this code does not fill the drop down menu with data drawn from a sql database!? It executes without error but not data.... [code] <?php include 'db.php'; $query= mysql_query("SELECT * FROM ssrfc_images") or die (mysql_error()); $result = mysql_query($query); echo '<select name="images" size=1>'; while($row = mysql_fetch_array($result)){         echo '<option value="' . $row['id'] . '">' .  $row['image'] . '</option> \n';     } echo '</select>'; ?>[/code]
  8. I know im probably being dumb here but what is the correct syntax to use in a query when you want to return more than one result that has the same data in a field of the database?? for example: [code] SELECT * FROM table WHERE topicid = $id [/code] I cant only get it to return to me one result otherwise i get a syntax error. Basicly its for a comments page it will show all the comments made on a topic contained in another table. It seems to be finding only one match at the moment and not all of them!
  9. All i notice is that your form action is a html file and not php. Your processing code wont work if its not in php.
  10. Hey all im working on a script that allows a user to upload videos. Now i use the exact same script to upload images and it works perfectly and there is no file extension filtering in the script but for some reason when i try to upload a video it processes the file then says its a possible file attack. I think it may be because somehow it times out?? Could someone help me out? Thank [code]<? include 'db.php'; $imgname = ($_FILES['userfile']['name']); $uploaddir = '../../video/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); $filename = basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { header ("Location: ../media.php"); } else {   echo "Possible file upload attack!\n"; } $sql = mysql_query("INSERT INTO ssrfc_videos(video) VALUES('$filename')") or die (mysql_error()); if(!$sql){ echo 'There has been an error while trying to upload your image.'; } else { $id = mysql_insert_id(); } ?>[/code]
  11. Hi all ive currently got some news displaying which i have limited to 75 characters using the substr() function so the user can click and read more. Im just wondering if there is a way to get the script to not chop off the end of words. As every bit of news will be different lengths there is no garuntee that it will show whole words when it comes to the end of the string of 75 charcs. For example if i have news with the first sentance being displayed i want it to show like this: This is the first sentance of this news article. and not this: This is the first sentance of this ne Can anyone help?
  12. Hi all im having trouble with a script ive created to upload a image to a web server and at the same time upload some data into a sql datbase including the url to the image thats been uploaded. This is basicly two seperate scripts merged into one so im not too sure if its the streamline way to do it. It doesnt seem to work though although i dont get any errors. [code]<? include 'db.php'; //GET VARIABLES $title = $_POST['title']; $message = $_POST['message']; $publish = $_POST['publish']; $title = stripslashes($title); $message = stripslashes($message); $date = date("j F"); //UPLOAD IMAGE $imagename = basename($_POST['image_file']['name']); //echo $imagename; if(empty($imagename)) $error["imagename"] = "The name of the image was not found."; if(empty($error)) { $newimage = "../../images/newsimages/" . $imagename; //echo $newimage; $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(empty($result)) $error["result"] = "There was an error moving the uploaded file."; } //INSERT DATA INTO DATABASE $sql = mysql_query("INSERT INTO ssrfc_news (title, message, publish, image, date) VALUES('$title', '$message', '$publish', '$result', '$date')") or die (mysql_error()); if(!$sql){ echo 'There has been an error while trying to submit your post.'; } else { $id = mysql_insert_id(); } header("Location: ../news.php"); echo 'Your article has successfully been posted.'; ?>[/code] Any help would be great but im guessing that the problem lies around the $_post function.
  13. Hey everyone. Im currently building a CMS using a basic template created in dreamweaver. The problem im having is when including php files. I dont mean for headers or general layout but for content items. For example in the template ive included a php script file that shows how many members are online. Then on the pages that i create from that template i have things like displaying a little forum and league table. Trouble is for some reason on some pages the includes like the forum will come up with an mysql_query error because it cant connect to the database i.e it says the path ive directed it too to include the database connection doesnt exist but i know it does because it works fine when i quote out the members online include. This isnt just a problem with these files because it does the same thing with other files it just doesnt seem to like having more than one include on the same page but only in some cases! I hope that makes sense !
  14. I know this is far from the best way of storing images but i could never work out how to when uploading images to a directory at the same time upload its path to a sql table! Is that possible?
  15. Nope thats not the solution still the same problem :o( please somebody
  16. Ive also tried what you gave me round and it did work and only returned one result but it did exactly as the other scripts do just return binary instead of an image. I really dont understand as it works fine when you just print $imgdata and no html
  17. Try taking out the ' next to rank in your string
  18. What thorpe told me to do does work but now it is just showing the image as binary characters and not the image itself where as it does if you just do print $imgdata;
  19. Hi all im trying to display a news story with an uploaded image. Im new to working with images stored in a database so im not quite sure the best way to script it in different ways at the moment. But what im trying to do is get the result then refresh the headers and print out some html with the results variables embedded into the html as you can see in the script below: [code] <?php require_once('includes/db.php'); $query=("SELECT * FROM ssrfc_test ORDER BY id DESC LIMIT 0, 1"); $getdata = mysql_query($query) or die(mysql_error()); if($row = mysql_fetch_assoc($getdata)) { $imgtitle = htmlspecialchars($row["imgtitle"]); $imgdata = $row["imgdata"]; $id = $row["id"]; $title = $row["title"]; $message = $row["message"]; }else{         $errmsg = "MySql Error!"; } header("Content-type: image/jpeg"); print '<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="100%" border="1" cellspacing="2" cellpadding="0" bordercolor="#000000">   <tr>     <td width="2%">$id</td>     <td width="2%">$title</td>     <td width="2%">$message</td>     <td width="2%">$imgtitle</td>     <td width="92%">$imgdata</td>   </tr> </table> </body> </html>'; exit(); ?>[/code] All it does is just print the name of the variable. Ive tried a hundred different ways i can think of including echo() and printf() someone please help me out. Thanks
  20. Anyone please!? I really need to get this script working!
  21. Ok im getting somewhere now the code that heckenschutze has given me works apart from it wont show the images or the title. Although it does draw the title as an alt attribute. Someone please help i know im almost there with this! here is the page: [url=http://www.alns.co.uk/ssrfc/showall.php]http://www.alns.co.uk/ssrfc/showall.php[/url]
  22. Thanks for the link but ive already achieved what the tutorial explains. I know how to upload an image and display it. The only trouble is i want to display all the images in the database which is achievable in the code heckenschutze gave me but i cant get it to work  :-\
×
×
  • 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.