Jump to content

ozestretch

Members
  • Posts

    237
  • Joined

  • Last visited

Everything posted by ozestretch

  1. When the idea first went through my head it seemed easy... but am approaching 26th hour of being awake and have become hazy. 1: Can I use fgetcsv() with a database row[]? This is where variable 1, variable 2,variable 3 variable 4 variable 5, variable 6 variable 7, variable 8,variable 9 comes from. I assumed I need to fopen() etc... Am I on right track that I need to get each line into an array, then search each array for the common value? Once I found that line, I need to set that key with the new value. Trying this now.. <?php $grades = preg_replace('/\r\n|\r/', "\n", $row['setting']); $grades = explode("\n",$grades); $csetting = explode(",",$_POST['setting']); $var = $csetting[0]; foreach($grades as $value) { if(stristr($value,$var)){ // key of array to be replaced $foundkey = array_key($grades, $value); } } $grades[$foundkey] = $csettings; $mynewcsvrow = implode("\n",$grades); // insert back into database with new values ?>
  2. I have found that almost all tutorials that are posted to you for free, are in fact untested. That doesn't mean they do not work... but they may forget to cross their t's and dot their variables
  3. Not sure if that made sense. I have this: variable 1, variable 2,variable 3 variable 4 variable 5, variable 6 variable 7, variable 8,variable 9 And want to edit 1 line only. ie where: value1, value2,value3 I wish to add a new value to that line value1, value2,value3,new value or remove a line: value1, value2 The common value here is the prefixing value, in the above case, value 1. The posted data for adding would be posted as: value1, value2,value3,new value and likewise for removing value, would be: value1, value2 If I was replacing a value, that is easy, preg_replace(). But I need to find the line that is being changed, then apply the changes.
  4. Fair call, I did after all come here an hour or so ago to get help myself.... now 8am, no sleep.. will leave even the easy problems to you xperts
  5. function checkSomething($uuid){ GLOBAL $db; // This addition should do it $row = $db->query("select UUID from someTable WHERE UUID = $uuid"); if($db->affected_rows > 0){ return true; } else { return false; } }
  6. In other words, change this mail($emailSubject, $salesinfo, $body, $header); to this mail($salesinfo, $emailSubject, $body, $header);
  7. <? mail($to, $subject, $message, $headers); ?> I believe this is the mail() functions correct values.
  8. Was not sure how to title this post, but let me elaborate. I have the data in CSV format like so: variable 1, variable 2,variable 3 variable 4 variable 5, variable 6 variable 7, variable 8,variable 9 Each new line will have at least 1 variable and the first variable must not be changed (this is used as a reference) So if I was to change line 3, I would post something like this: variable 5, variable 6, variable 10 if I was adding to it, or variable 5 if I was removing item/s from it $csetting = explode(",",$_POST['setting']); $grades = preg_replace('/\r\n|\r/', "\n", $row['setting']); // $row['setting'] drawn from mysql in CSV format above $grades = explode("\n",$grades); $err=0; foreach($grades AS $key){ // get each new line if($key===$csetting[0]){ // only 1 name in records, was something deleted? if($key===$csettings){ // only 1 name in records, one name posted // no change needed $err++; }else{ // update with addition $allgrades.=$csettings.'\r\n'; } }elseif($key===$csettings){ // line equals post value $err++; }else{ $grades2 = explode(",",$key); foreach($grades2 AS $key2){ if($key2!=$csetting[0]){ $allgrades.=$key.'\r\n'; } } } } I am stumped basically, am I looking at this the wrong way? After 5 hours of retyping the same thing different ways, I got the feeling the tree I am barking at is actually a light pole. Thanks in advance
  9. wrong $description[$file][0]; right $description[$file]; ozestrech $foo = 'noob'; $ozestretch = $foo; echo $ozestretch
  10. $line echos nothing :-\ This is really the only way I know/thought I knew to do it. Any ideas?
  11. if (isset($_POST["password"]) && ($_POST["password"]=="$password") || ($_SESSION['login'])) I am no expert, but there would be no password posted if session is set for login. <?php $password = "hellothere"; // Modify Password to suit for access, Max 10 Char. if (isset($_POST['password']) && ($_POST['password']==$password)){ $_SESSION['login'] = 'whatiwantittobe'; header("Location: backtothispage.php"); // force reload of the page with login session }elseif(isset($_POST['password']) && ($_POST['password']!=$password)){ $_SESSION['errors'] = "Password Incorrect"; header("Location: backtothispage.php"); // force reload of the page with login session } ?> then if(isset($_SESSION["login"])){ // my private stuff here } should be enough but not tested.
  12. I have a text file which contains lines, each line contains information separated by comma eg: myimage.jpg,My Image Description anotherimage.jpg,And another description here ..... so on I am using the below code to match the first variable (the image name) to the actual image located on server and return its description. ??? ??? It seems to do all of it fine, except it is only returning the first character of the description ??? ??? $images = "gallery/"; # Location of images $text = "gallery.txt"; $fh=@fopen($text, "r"); while(!feof($fh)) { $line=fgets($fh); $temp = explode(",", $line); $description[$temp[0]] = $temp[1]; unset($temp); } if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($images,"/")) { $files[] = $file; } } closedir($handle); } And to display the description I call for foreach($files as $file) { echo '<img src="' . $images . $file .'" /><br />' . $description[$file][0]; } Any ideas are welcomed, thanks
×
×
  • 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.