Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. oops update $query = sprintf("SELECT * FROM spares where ref like \"%%s%\" LIMIT 1",mysql_real_escape_string($ref)); to $query = sprintf("SELECT * FROM spares where ref like '%s' LIMIT 1","%".mysql_real_escape_string($ref)."%");
  2. Few updates Your need to update the select database line <?php error_reporting (E_ALL ^ E_NOTICE); $idir = "uploads/"; // Path To Images Directory $usr = "usr"; $pwd = "pass"; $db = "db"; $host = "srv"; /***********************Upload File***********************/ 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 } } /***********************Get Record***********************/ $ref = (!empty($_GET['ref']))?trim($_GET['ref']):""; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid){ echo("ERROR: " . mysql_error() . "\n"); } $db_selected = mysql_select_db('foo', $cid); //UPDATE $query = sprintf("SELECT * FROM spares 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) { echo "FOUND"; $ref=$record["ref"]; $title=$record["title"]; $descr=$record["descr"]; $partno=$record["partno"]; $price=$record["price"]; $avail=$record["avail"]; $image=$record["image"]; }else{ echo "NOT FOUND"; $ref=0; $title=""; $descr=""; $partno=""; $price=""; $avail=""; $image=""; } /***********************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["partno"]; $price=$_POST["price"]; $avail=$_POST["avail"]; $image=$_POST["image"]; # setup SQL statement $query = sprintf("UPDATE `spares` SET `title` = '%s',`descr` = '%s',`partno` = '%s',`price` = '%s',`avail` = '%s',`image` = '%s' WHERE `spares`.`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($image),mysql_real_escape_string($ref)); #execute SQL statement $result = mysql_db_query($db,$query,$cid) or die($query."<br>".mysql_error()); //$ID=mysql_insert_id(); //Pointless its an updatre not an insert!! # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo "<P>Part updated</P>\n"; } ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?> " method ="post"> <div class="input_row"> <div class="input_titles">Title:</div> <div class="input_box"><INPUT NAME="title" TYPE="text" id="title" VALUE="<?php echo $title; ?>" SIZE=50> e.g. Avondale Dart Rooflight </div> </div> <div class="input_row"><div class="input_titles">Description:<br /><br />(Use this space to add further descriptive text about this spare part e.g. dimensions etc.)</div><div class="input_box"><textarea name="descr" cols="50" rows="10" id="descr" type="text" value="<?php echo $descr; ?>"</textarea></div> </div> <div class="input_row"><div class="input_titles">Part number:</div><div class="input_box"><input name="partno" type="text" id="partno" value="<?php echo $partno; ?>" size="10" /> </div></div> <div class="input_row"><div class="input_titles">Price (£) :</div><div class="input_box"><input name="price" type="text" id="price" value="<?php echo $price; ?>" size="15" /> (number only, no commas or pound signs)</div></div> <div class="input_row"><div class="input_titles">In stock:</div><div class="input_box"><input name="avail" type="text" id="avail" value="<?php echo $avail; ?>" size="4" /> (number only)</div></div> <input type = "hidden" name="MAX_FILE_SIZE" value = "102400"> <input type = "hidden" name="ref" value = "<?php echo $ref; ?>"> <div class="input_row"><div class="input_titles">Select image:</div><div class="input_box"><input type = "file" name = "fupload"></div></div> <div class="input_row"><div class="input_titles"><input name="submit" type="submit" value="Update part" /></div></div> </FORM>
  3. OKay heres a single script (untested) if you call it test.php and open test.php?ref=something it should open that record and allow you to edit it, <?php error_reporting (E_ALL ^ E_NOTICE); $idir = "uploads/"; // Path To Images Directory $usr = "usr"; $pwd = "pass"; $db = "db"; $host = "srv"; /***********************Upload File***********************/ 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 } } /***********************Get Record***********************/ $trimmed = (!empty($_GET['ref']))?trim($_GET['ref']):""; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid){ echo("ERROR: " . mysql_error() . "\n"); } $query = "SELECT * FROM spares where ref like \"%$trimmed%\" LIMIT 1"; $result = mysql_query($query); $record = mysql_fetch_assoc($result); if(mysql_num_rows($result) > 0) { echo "FOUND"; } $ref=$record["ref"]; $title=$record["title"]; $descr=$record["descr"]; $partno=$record["partno"]; $price=$record["price"]; $avail=$record["avail"]; $image=$record["image"]; /***********************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["partno"]; $price=$_POST["price"]; $avail=$_POST["avail"]; $image=$_POST["image"]; # double-up apostrophes -- WHY ? use mysql_real_escape_string /* $title = str_replace("'","''",$title); $descr = str_replace("'","''",$descr); $partno = str_replace("'","''",$partno); $price = str_replace("'","''",$price); $avail = str_replace("'","''",$avail); */ # setup SQL statement $SQL = sprintf("UPDATE `spares` SET `title` = '%s',`descr` = '%s',`partno` = '%s',`price` = '%s',`avail` = '%s',`image` = '%s' WHERE `spares`.`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($image),mysql_real_escape_string($ref)); #execute SQL statement $result = mysql_db_query($db,"$SQL",$cid); //$ID=mysql_insert_id(); //Pointless its an updatre not an insert!! # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo "<P>Part updated</P>\n"; } ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?> " method ="post"> <div class="input_row"> <div class="input_titles">Title:</div> <div class="input_box"><INPUT NAME="title" TYPE="text" id="title" VALUE="<?php echo $title; ?>" SIZE=50> e.g. Avondale Dart Rooflight </div> </div> <div class="input_row"><div class="input_titles">Description:<br /><br />(Use this space to add further descriptive text about this spare part e.g. dimensions etc.)</div><div class="input_box"><textarea name="descr" cols="50" rows="10" id="descr" type="text" value="<?php echo $descr; ?>"</textarea></div> </div> <div class="input_row"><div class="input_titles">Part number:</div><div class="input_box"><input name="partno" type="text" id="partno" value="<?php echo $partno; ?>" size="10" /> </div></div> <div class="input_row"><div class="input_titles">Price (£) :</div><div class="input_box"><input name="price" type="text" id="price" value="<?php echo $price; ?>" size="15" /> (number only, no commas or pound signs)</div></div> <div class="input_row"><div class="input_titles">In stock:</div><div class="input_box"><input name="avail" type="text" id="avail" value="<?php echo $avail; ?>" size="4" /> (number only)</div></div> <input type = "hidden" name="MAX_FILE_SIZE" value = "102400"> <input type = "hidden" name="ref" value = "<?php echo $ref; ?>"> <div class="input_row"><div class="input_titles">Select image:</div><div class="input_box"><input type = "file" name = "fupload"></div></div> <div class="input_row"><div class="input_titles"><input name="submit" type="submit" value="Update part" /></div></div> </FORM>
  4. The page will always update.. thats what you wrote! can you post a more complete script and i'll over give it the once over (i'm at work so kinda hard) to write too much on here!
  5. Well that suggests that $_GET['ref'] ; isn't being set! your need to add that to your form ie <form enctype="multipart/form-data" action="<?php print $_SERVER['PHP_SELF']."?".$trimmed ?> " method ="post"> also theirs no quotes on the update line $SQL = "UPDATE `spares` SET `title` = '$title',`descr` = '$descr',`partno` = '$partno',`price` = '$price',`avail` = '$avail',`image` = '$image' WHERE `spares`.`ref` ='$trimmed' ";
  6. and what database are you talking to ? ie $db_selected = mysql_select_db('foo', $cid);
  7. put another echo after the include, without an error its kinda hard to say but it looks like you messed something up!
  8. add this to the start! <?php echo "Testing"; ?>
  9. This is the code i just ran and it works fine <?php //MyEmail eg myemail@gmail.com //MyPassword eg mypassword error_reporting(E_ALL); require_once('class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $body = "testing <b>PHP Mailer</b> wooohooo"; $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "MyEmail"; // GMAIL username $mail->Password = "My Password"; // GMAIL password $mail->SetFrom('MyEmail', 'First Last'); $mail->AddReplyTo('MyEmail', 'First Last'); $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "MyEmail"; $mail->AddAddress($address, "John Doe"); #$mail->AddAttachment("images/phpmailer.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> you should be getting an error at the very least! Example Output
  10. Can you post your code as you must be missing something
  11. change <?php require_once('../class.phpmailer.php'); to <?php error_reporting(E_ALL); require_once('class.phpmailer.php');
  12. Also theres an SQL injection point on the login part but at a guess WHERE user_name='$user_nameFromForm' $user_nameFromForm is unfiltered, but i would guess that the problem is with the $_POST['user_name'] is that being set ? you may wish to check that, this $sql = "INSERT INTO Login (user_name) VALUE ('$clean_data[user_name]')"; should be $sql = "INSERT INTO Login (user_name) VALUE ('{$clean_data['user_name']'})";
  13. remove the white space after the first EODl 'EOD; ' should be 'EOD;' (excluding the quotes) EDIT: full code if (($i == date("j")) && ($month == date("m")) && ($year == date("Y"))) { $EventEOD .=<<<EOD <td width="110px" height="103px" valign="top" align="center"> <div class="date_header_today"> <font class="days_today">$i</font> </div> EOD; } else { $EventEOD .=<<<EOD <td width="110px" height="103px" valign="top" align="center"> <div class="date_header_today"> <font class="days">$i</font> </div> EOD; } Note how else is green on mine (due to correct parsing)
  14. This depends on what stuff your talking about.. if this is to plugin into a calendar you already use.. then we need to know what you use! other than that i have no idea what your download Read this for creating a Simple PHP Calendar
  15. Very nice, but did you read all of my last post ?
  16. That problem would be likely be caused by the form.. I'm guessing that you have, <form action="<?php echo $loginFormAction; ?>"> and <?php echo $loginFormAction; ?> is being displayed on the form, this would mean the form isn't being parsed, So.. at a guess i would say your form page is a html file not a php one, so if your form page is called myfrom.html, try changing it to myform.php
  17. You don't need to make any changes to the php.ini file, You did something wrong, if you did it correctly your get either or
  18. 2 things #1 you need to use quotes file_get_contents(EditCode.php); should be file_get_contents("EditCode.php"); #2 if the file contains php code your get the php code back (not the results) using include will give the php code results
  19. It doesn't matter..
  20. Have you tried using iconv if the encoding is this may fix it $string = iconv("UTF-8","UTF-8//IGNORE",$string);
  21. @Maq, yeah but the $conn = fopen($url, "r"); and fclose($conn); are not required! unless your using fread(), and only reading a small chunk tail what data do you wish to extract, can you post some sample of what $html returns and what part you want from it
  22. $contents = file_get_contents("myfile.html"); //or include("myfile.html");
  23. I'm going to mark this as solved but please remember to click topic solved (bottom left)
  24. so it doesn't list the file! Random tests just some ideas if (file_exists($this->path . $this->path_compile . $folder . $file)) { to $theFile = $this->path . $this->path_compile . $folder . $file; if (file_exists($theFile)) { Just to see, If this is running on linux, check permissions if your creating the file just before using file_exists() maybe add a sleep(2), try renaming the file via the OS to "test" and then check it.. and if all else fails call the ghost busters EDIT: just read your last post, are you sure the zip file is being closed!
  25. updated <?php if (file_exists($this->path . $this->path_compile . $folder . $file)) { echo 'got it'; }else{ echo 'tough luck, nope: ' . $this->path . $this->path_compile . $folder . $file; if(is_dir($this->path)) { echo "Found: ".$this->path."<br />\n"; if(is_dir($this->path.$this->path_compile)) { echo "Found: ".$this->path.$this->path_compile."<br />\n"; if(is_dir($this->path.$this->path_compile.$folder)) { echo "Found: ".$this->path.$this->path_compile.$folder."<br />\n"; $dir = $this->path.$this->path_compile.$folder; if ($dh = opendir($dir)) { while (($file2 = readdir($dh)) !== false) { if($file2 == $file) echo "<B>FOUND:</B>"; //yeah right echo "filename: $file2 : <br />\n"; } closedir($dh); } } } } } ?> EDIT: cleaned tabs in code
×
×
  • 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.