Jump to content

joshgarrod

Members
  • Posts

    283
  • Joined

  • Last visited

    Never

Everything posted by joshgarrod

  1. Hi, thanks for the reply. thanks.php definately exists, I am sorry, it is not a 404 error, this is the error I am getting: "Internet Explorer cannot display the webpage". Also the URL in the address bar remains on the advertise.php page which is where the user starts off?
  2. Hi, I have a script inserting data into a table. I think the problem is something to do with the exit part of the script as it supposed to go to a page named thanks.php once it has finished. The data is inserted into the table but then I get a 404 error? Script: <?php $idir = "uploads/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload2'])){ //upload the image to tmp directory $url = $_FILES['fupload2']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload2']['type'] == "image/jpg" || $_FILES['fupload2']['type'] == "image/jpeg" || $_FILES['fupload2']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload2']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload2']['tmp_name'], "$idir" . $_FILES['fupload2']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload3'])){ //upload the image to tmp directory $url = $_FILES['fupload3']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload3']['type'] == "image/jpg" || $_FILES['fupload3']['type'] == "image/jpeg" || $_FILES['fupload3']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload3']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload3']['tmp_name'], "$idir" . $_FILES['fupload3']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload4'])){ //upload the image to tmp directory $url = $_FILES['fupload4']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload4']['type'] == "image/jpg" || $_FILES['fupload4']['type'] == "image/jpeg" || $_FILES['fupload4']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload4']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload4']['tmp_name'], "$idir" . $_FILES['fupload4']['name']); // Move Image From Temporary Location To Permanent Location } } error_reporting (E_ALL ^ E_NOTICE); $usr = "fghfh"; $pwd = "fghfh"; $db = "fhfhhh"; $host = "213.45454818"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { $company = mysql_real_escape_string($_POST['company']); $website = mysql_real_escape_string($_POST['website']); $email = mysql_real_escape_string($_POST['email']); $tel = mysql_real_escape_string($_POST['tel']); $location = mysql_real_escape_string($_POST['location']); $address1 = mysql_real_escape_string($_POST['address1']); $address2 = mysql_real_escape_string($_POST['address2']); $address3 = mysql_real_escape_string($_POST['address3']); $address4 = mysql_real_escape_string($_POST['address4']); $postcode = mysql_real_escape_string($_POST['postcode']); $descr = mysql_real_escape_string($_POST['descr']); $lowseason = mysql_real_escape_string($_POST['lowseason']); $midseason = mysql_real_escape_string($_POST['midseason']); $highseason = mysql_real_escape_string($_POST['highseason']); $live = "No"; $image1 = mysql_real_escape_string("$idir" . $_FILES['fupload2']['name']); $image2 = mysql_real_escape_string("$idir" . $_FILES['fupload3']['name']); $image3 = mysql_real_escape_string("$idir" . $_FILES['fupload4']['name']); $logo = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); //echo "<img src=\"images/processing.gif\">"; //$model_chk = (!isset($_POST['model']) || trim($_POST['model']) == "") //? die ('ERROR: Enter a model') : //mysql_escape_string(trim($_POST['model'])); $SQL = " INSERT INTO mhhire "; $SQL .= " (company, website, email, tel, location, address1, address2, address3, address4, postcode, descr, lowseason, midseason, highseason, image1, image2, image3, logo, live) VALUES "; $SQL .= " ('$company', '$website', '$email', '$tel', '$location', '$address1', '$address2', '$address3', '$address4', '$postcode', '$descr', '$lowseason', '$midseason', '$highseason', '$image1', '$image2', '$image3', '$logo', '$live') "; $result = mysql_db_query($db,$SQL,$cid); $last=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } //echo ("<P><B>Your caravan has been added to our classified section</B></P>\n"); //printf("<a href=\"view_used_caravan.php?ref=". mysql_insert_id() ."\">Click here to view your advert</a>"); header("location:thanks.php"); exit(); } ?> Thanks
  3. Hi, thanks for your prompt reply. What i mean by "appears" is that there are no error messages and it prints "part updated". I have loads of MySQL functions working with my server. This code is in a password protected area for administrative purposes so hackers will not be able to access. Could you explain in my simpleton language what you mean by this please lol Is it absolutely necessary to change all of my mysql_db_query() to mysql_select_db and mysql_query as I have many other scripts working with this. Thanks for your time
  4. Hi, I am having problems updating records from a form. The data is displaying in the form, however, upon submitting the form, it appears to have updated but it actually hasn't. Please help: <?php $ref = (!empty($_GET['ref']))?trim($_GET['ref']):""; $table = (!empty($_GET['table']))?trim($_GET['table']):""; if (isset($_POST['submit'])){ $ref=$_POST["ref"]; $title=$_POST["title"]; $descr=$_POST["descr"]; $partno=$_POST["stocknu"]; $price=$_POST["price"]; $category=$_POST["category"]; # setup SQL statement $query = sprintf("UPDATE `$table` SET `title` = '%s',`descr` = '%s',`stocknu` = '%s',`price` = '%s' WHERE `$table`.`ref` ='%s' LIMIT 1", mysql_real_escape_string($title),mysql_real_escape_string($descr),mysql_real_escape_string($partno),mysql_real_escape_string($price),mysql_real_escape_string($avail),mysql_real_escape_string($category),mysql_real_escape_string($ref)); #execute SQL statement $result = mysql_db_query($db,$query,$cid) or die($query."<br>".mysql_error()); # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo "<P>Part updated</P><br />"; } ?> ?>
  5. Hi all, I have used this script dozens of times, but it won't work all of a sudden, it performs as though it has but the update is not being made. Any help please? <?php /***********************Get Record***********************/ $ref = (!empty($_GET['ref']))?trim($_GET['ref']):""; $table = (!empty($_GET['table']))?trim($_GET['table']):""; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid){ echo("ERROR: " . mysql_error() . "\n"); } $db_selected = mysql_select_db('quest', $cid); //UPDATE $query = sprintf("SELECT * FROM $table where ref like '%s' LIMIT 1","%".mysql_real_escape_string($ref)."%"); $result = mysql_query($query) or die($query."<br>".mysql_error()); $record = mysql_fetch_assoc($result); if(mysql_num_rows($result) > 0) { $ref=$record["ref"]; $title=$record["title"]; $descr=$record["descr"]; $partno=$record["stocknu"]; $price=$record["price"]; $category=$record["category"]; }else{ echo "NOT FOUND"; $ref=0; $title=""; $descr=""; $partno=""; $price=""; $category=""; } /***********************Save Record***********************/ # this is processed when the form is submitted # back on to this page (POST METHOD) if (isset($_POST['submit'])){ $ref=$_POST["ref"]; $title=$_POST["title"]; $descr=$_POST["descr"]; $partno=$_POST["stocknu"]; $price=$_POST["price"]; $category=$_POST["category"]; # setup SQL statement $query = sprintf("UPDATE `$table` SET `title` = '%s',`descr` = '%s',`stocknu` = '%s',`price` = '%s',`category` = '%s' WHERE `$table`.`ref` ='%s' LIMIT 1", mysql_real_escape_string($title),mysql_real_escape_string($descr),mysql_real_escape_string($partno),mysql_real_escape_string($price),mysql_real_escape_string($avail),mysql_real_escape_string($category),mysql_real_escape_string($ref)); #execute SQL statement $result = mysql_db_query($db,$query,$cid) or die($query."<br>".mysql_error()); # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo "<P>Part updated</P><br />"; } ?>
  6. Hi everyone. I am in need of a login script, I found this one on the web. I am not familiar with cookies at all, the model doesn't seem to work. What is wrong? At the moment, if you try to access protected_page.php it redirects to login.php which is what it should do. However, when I log in with the correct username and password it just reloads login.php and doesn't redirect to protected_page.php as it should. Thanks is advance login.php <?php $act = $_GET['act']; //retrives the page action if(empty($act)) //if there is no action { echo('<form action="login.php?act=auth" method="post" name="loginform" id="loginform"> <p>Username <input type="text" name="user"> </p> <p>Password <input type="password" name="pass"> </p> <p> <input type="submit" name="Submit" value="Login"> </p> </form>'); } elseif($act == "auth") //if our page action = auth { $user = $_POST['user']; //pulls the username from the form $pw = $_POST['pass']; //pulls the pass from the form<strong></strong> $pass = md5($pw); //makes our password an md5 include("connect.php"); //connects to our mysql database $login = mysql_query("SELECT * FROM `users` WHERE `user` = '$user' AND `pass` = '$pass`"); //selects info from our table if the row has the same user and pass that our form does if(!mysql_num_rows($login)) //if the username and pass are wrong { header("Location: login.php"); //redirects to our login page die(); //stops the page from going any further } else { setcookie("user", $user, time()+3600);//sets our user cookie setcookie("pass", $pass, time()+3600);//sets our pass cookie header("Location: protected_pag.php");//instead of yourpage.php it would be your protected page } } ?> protect.php <?php $user = $_COOKIE['user']; //gets the user from the cookies $pass = $_COOKIE['pass']; //gets the pass from cookies include("connect.php"); // connects to our database $login = mysql_query("SELECT * FROM `users` WHERE `user` = '$user' AND `pass` = '$pass`"); //selects info from our table if the row has the same user and pass that our cookies do if(!mysql_num_rows($login)) //if the username and pass are wrong { header("Location: login.php"); //redirects to our login page die(); //stops the page from going any further } ?> protected_page.php <?php require("protect.php"); ?>
  7. I would say the easiest way would be to start looking at some xml options
  8. Thanks, for your input everyone. It was the looping and recalling the variables from $query
  9. This is the complete section of code: <?php //error_reporting(E_ALL); $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("quest", $con); $page = $_GET['ref']; // This will be the ID of the page $page = mysql_real_escape_string(strip_tags($page)); $query = mysql_query("SELECT * FROM articles WHERE `ref` = '$page'"); if(mysql_num_rows($query)==0){ die("Sorry, but the page doesnt exist!"); }else{ while($info = mysql_fetch_array($query)){ $title = $info ['title']; $category = $info ['category']; $content = $info ['content']; $postby = $info ['postby']; $timedate = $info ['timedate']; $image = $info ['image']; function custom_title($info) //sets the function to create the custom title { $title = $info ['title']; return "$title - Blog - About Caravans"; } function custom_keywords($info) //sets the function to create the custom keywords for meta tags { $title = $info ['title']; $category = $info ['category']; return "$title, $category, caravan blog, motorhome blog"; } function custom_desc($info) //sets the function to create a custom meta description { $title = $info ['title']; return "$title blog entry. Find more at www.aboutcaravans.co.uk"; } ?>
  10. that is not the full code, just the code around line 26
  11. Here is my code: <?php if(mysql_num_rows($query)==0){ die("Sorry, but the page doesnt exist!"); }else{ while($info = mysql_fetch_array($query)){ $title = $info ['title']; $category = $info ['category']; $content = $info ['content']; $postby = $info ['postby']; $timedate = $info ['timedate']; $image = $info ['image']; function custom_title($info) //sets the function to create the custom title { $title = $info ['title']; return "$title - Blog - About Caravans"; } function custom_keywords($info) //sets the function to create the custom keywords for meta tags { $title = $info ['title']; $category = $info ['category']; return "$title, $category, caravan blog, motorhome blog"; } function custom_desc($info) //sets the function to create a custom meta description { $title = $info ['title']; return "$title blog entry. Find more at www.aboutcaravans.co.uk"; } ?>
  12. I think it probably is duplicate variable names, it doesn't really matter then I guess as it won't show when it's live. Thanks
  13. Hi, I am getting the warning quoted below. However, it only comes up since I have "included" another script, when I remove it, the warning doesn't appear. All the code seems to be working fine. The page the warning is referring to isn't even the file being "included"???: Thanks
  14. I use the following: <?php $count = 10; $words = "blah blah blah"; $shortwords = substr($words,0,$count); echo "$shortwords..."; ?> Giving the output: blah blah ... Obviously change $count to set the character limit.
  15. This is what the code should look like: <p>Hello<p/><br/> <?php $name = "Melissa"; $age = 21; ?> <p>Hello Again<p/> <?php echo "$name"; echo "$age"; ?>
  16. Hi, I am trying to create a page that list comments that have been submitted about articles in my blog. The list is for the admin side so that he / she can send them live or delete them. However, for some reason they won't even display. The warning I am getting and my code is below. Thanks in advance <?php error_reporting (E_ALL ^ E_NOTICE); $usr = "usr"; $pwd = "pwd"; $db = "quest"; $host = "host"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } $query = mysql_query("SELECT * FROM comments ORDER BY ref"); if(mysql_num_rows($query)==0){ echo "<p>There are currently no new comments</p>"; }else{ while($info = mysql_fetch_array($query)){ $ref = $info ['ref']; $comment = $info ['comment']; $name = $info ['name']; $submitted = $info ['submitted']; $live = $info ['live']; if ($live == "No") { echo "<p>Comment by - $name on $submitted</p> <p>$comment</p> <p><a href=\"accept_comment.php?ref=$ref\">Go live</a> | <a href=\"delete_comment.php?ref=$ref\">Remove</a></p> <hr class=\"hr\" width=90%>"; } else { } } } ?>
  17. Hi all, I am up against my biggest challenge yet! I have been asked to code a blog and the only thing that i can't get working poperly is the comment system. The following code is an include on the article page: <?php error_reporting(E_ALL); $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("quest", $con); $db = mysql_select_db("quest", $con); if ($_POST['submit']) { $comment = mysql_real_escape_string($_POST['comment']); $name = mysql_real_escape_string($_POST['name']); $submitted = mysql_real_escape_string($_POST['timedate']); $live = "No"; $articleref = mysql_real_escape_string($_POST['articleref']); $page = mysql_real_escape_string($_POST['page']); $SQL = " INSERT INTO comments "; $SQL .= " (comment, name, submitted, live, articleref) VALUES "; $SQL .= " ('$comment', '$name', '$submitted', '$live', '$articleref') "; $result = mysql_db_query($db,$SQL,$cid); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } //show comments (if any) code $query = mysql_query("SELECT * FROM comments WHERE `articleref` = '$page'"); if(mysql_num_rows($query)==0){ echo "<p>There are currently no comments for this article - please use the form below if you wish to make a comment</p>"; }else{ while($info = mysql_fetch_array($query)){ $comment = $info ['comment']; $name = $info ['name']; $submitted = $info ['submitted']; $live = $info ['live']; if ($live == "Yes") { echo "<p>Comment by - $name on $submitted</p> <p>$comment</p><hr class=\"hr\" width=90%>"; } else { } } } //header("location:thanks_comment.php"); //exit(); } ?> From this I am getting the following errors:
  18. Ok, sorry I get it. Set the variable before the loop with no value. I will try it.
  19. How do I get the information to set the variable $temp_category before the loop?
  20. Ok here is my code, thanks: <?php mysql_connect("host", "user", "pass") or die(mysql_error()); mysql_select_db("quest") or die(mysql_error()); $query = ("SELECT * FROM directory ORDER BY category ASC"); $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); while($row = mysql_fetch_object($result)) { $ref = $row->ref; $category = $row->category; $count = 120; $company = $row->company; $descr = $row->descr; $descrshort = substr($descr,0,$count); //limiting the amount of characters set by var count $web = $row->web; $tel = $row->tel; $road = $row->road; $town = $row->town; $county = $row->county; $temp_category = $category; if ($category != $temp_category){ #variable has changed;} echo "<h1>$category</h1>"; } else { #variable is the same; echo "<div id=\"show_row\"><h1>$company</h1><strong>Location: </strong>$town, $county<br /><br />$descrshort ...<a href=\"view_company_details.php?ref=$ref\">More>></a></div>"; $temp_category = $category; } } ?>
  21. but when you compare $variable and $oldvariable, you haven't actually set $oldvariable, sorry this ois really confusing me...
  22. But with a loop it won't work as it resets the variable back every time around, or is there a way to prevent this?
×
×
  • 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.