Jump to content

RyanSF07

Members
  • Posts

    221
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

RyanSF07's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Well I'll be darn. Thanks Jessica.
  2. Hello, This code: $textlevel= $row['level_text']; $oldlevel = array("Intermédio", "Intermédio avançado"); $newlevel = array("intermediate", "high_intermediate"); $textlevel = str_replace($oldlevel , $newlevel , $textlevel); spits out "intermediate avançado" instead of "high_intermediate" How do I join "Intermédio" and "avançado" so that "Intermédio avançado" is in fact replaced with high_intermediate instead of only the first work replaced? thank you for your help, Ryan
  3. Hi All, I need some help blocking files that don't pass authentication from being uploaded to the server. Here is my script (below). It correctly throws errors, but regardless of error / no-error, the file is uploaded. For example, the only files allowed to be uploaded should be .png, .jpeg, .gif -- but I see .flv .docx etc in the destination folder. You'll see below a variable for each of the error messages. They basically say that the file name is too long, too big, not an allowed file type, or English characters only allowed in file title name. Again the errors work properly, but regardless files are uploaded to the "quiz_images" folder. What do I need to do to stop the upload if an error is triggered? Thank you for your help... here is the code snip: $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'quiz_images/'; $fieldname = 'file'; if ($_POST[submit]) { if ($_POST[title] <> "") { $a = TRUE; } else { $a = FALSE; $content .= "<p>$enter_title</p>\n"; } if ($_POST[video] <> "") { $b = TRUE; } else { $b = FALSE; $content .= "<p>$enter_embed</p>\n"; } if ($_POST[description_text] <> "") { $c = TRUE; } else { $c = FALSE; $content .= "<p>$enter_description</p>\n"; } if ($_POST[submit] <> "") { $f = TRUE; } else { $f = FALSE; $content .= "<p>$sorry_error</p>\n"; } if (is_uploaded_file($_FILES[$fieldname]['tmp_name'])) { $g = TRUE; } else { $g = FALSE; $content .= "<p>$sorry_error</p>\n"; } if (getimagesize($_FILES[$fieldname]['tmp_name'])){ $h = TRUE; } else { $h = FALSE; $content .= "<p>$error2</p>\n"; } if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 50000)) { $i = TRUE; } else { $i = FALSE; $content .= "<p>$error2</p>\n"; } if(preg_match('#^[a-z0-9_\s-\.]*$#i', $pic) ) { $k = TRUE; } else { $k = FALSE; $content .= "<p>$error3</p>\n"; } $desc_length = strlen($pic); $limit = 40; if ($desc_length <= $limit) { $l = TRUE; } else { $l = FALSE; $content .= "<p>$error4</p>\n"; } $now = time(); while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'])) { $now++; } if (move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename)){ $j = TRUE; } else { $j = FALSE; $content .= "<p>$enter_thumb</p>\n"; } $pic=$now++.'-'.$_FILES[$fieldname]['name']; if ($a AND $b AND $c AND $f AND $g AND $h AND $i AND $j AND $k AND $l) {............
  4. Hi Guys, I have this bit of code which only allows one single user to view the page (which works great and there are no problems), but I'd like to add another user's id so that she can view it as well. What is the correct way to change this "if clause" so that both users 123 and 456 can view the page? if ($_SESSION[user_id] == 123) { include("admin_nav.inc"); ...... Thank you for your help!
  5. I was able to get everything to work using string replace. Pulled the level_text from the database and modified it to format the correct, level specific url. Thanks! Ryan
  6. so trying to do something like this: switch($row['level_text']) { case "beginning": $page = "beginning.php?id="; break; case "low_intermediate": $page = "low_intermediate.php?id="; break; case "intermediate": $page = "intermediate.php?id="; break; case "high_intermediate": $page = "high_intermediate.php?id="; break; } The $page variable should be set based on the $row[level_text]. For example, if the $row[level_text] = low_intermediate, the $page variable would equal: low_intermediate.php?id= and the link <a href=\"$page" . $row['id'] ."\"></a> would go to: <a href=\"low_intermediate.php?id=" . $row['id'] ."\"></a> (the id's are working just fine -- it's getting that $page variable to set right that's giving me trouble.)
  7. Thank you Flappy_Warbucks, Sorry for the delayed reply. I have this array pulling 5 items into a table: while($row = mysql_fetch_array($result)) { Those items become links to the content. I'd like to make the first part of the link dynamic, so that the content can display on a level specific page. For example, instead of the 5 items pulled from db linked like this: <a href=\"default-page.php?id=" . $row['id'] ."\"></a> They would be like this: <a href=\"beginning.php?id=" . $row['id'] ."\"></a> <a href=\"low_intermediate.php?id=" . $row['id'] ."\"></a> <a href=\"intermediate?id=" . $row['id'] ."\"></a> <a href=\"high_intermediate?id=" . $row['id'] ."\"></a> .. again depending on the $row[level_text] Does that make sense? Thank you so much for your help with this!
  8. Actually -- that was close but not spot on... Trying to do more like this: switch($row['level_text']) { case "beginning": $page = "beginning.php?id="; break; case "low_intermediate": $page = "low_intermediate.php?id="; break; case "intermediate": $page = "intermediate.php?id="; break; case "high_intermediate": $page = "high_intermediate.php?id="; break; default: $page = "default.php?id="; //incase something goes wrong somewhere. Always plan to for things to go wrong } echo $page; The echo should produce something like: (there are 5 instances displayed) high_intermediate.php?id= beginning.php?id= beginning.php?id= low-intermediate.php?id= high-intermediate.php?id=
  9. looks like that is going to work. I'll keep playing with it. thank you!
  10. now trying this -- on the right track? not working yet... switch ($page) { case label1: if ($row['level_text'] == "beginning") { $page == "beginning.php?id="; } break; case label2: if ($row['level_text'] == "low_intermediate") { $page == "low_intermediate.php?id="; } break; case label3: if ($row['level_text'] == "intermediate") { $page == "intermediate.php?id="; } break; case label4: if ($row['level_text'] == "high_intermediate") { $page == "high_intermediate.php?id="; } } echo $page;
  11. also, it looks like $row[level_text] has been set to equal "beginning" in other places where that $row echo'd onto the page...
  12. I tried this: if ($row['level_text'] == "beginning") { $page == "beginning.php?id="; } elseif ($row['level_text'] == "low_intermediate") { $page == "low_intermediate.php?id="; } elseif ($row['level_text'] == "intermediate") { $page = "intermediate.php?id="; } elseif ($row['level_text'] == "high_intermediate") { $page == "high_intermediate.php?id="; } echo $page; and get: beginning.php?id=beginning.php?id=beginning.php?id=beginning.php?id=beginning.php?id=
  13. thanks .. I'll google Switch. I'm sorry... that was just a snip. The script itself works (the complete script where the id is set) but all "ids" play on the same page. I'm trying to set a "page" variable so that the content doesn't have to play on one set page, rather a "level specific" page base on the row[level_text]
  14. Hello, I'm trying to set a variable based on a word that is pulled out of the DB in an array. What is the correct what of doing this? Currently I'm trying this without success: while($row = mysql_fetch_array($result)) { if ($row['level_text'] = "beginning") { $page = "beginning.php?id="; } elseif ($row['level_text'] = "low_intermediate") { $page = "low_intermediate.php?id="; } elseif ($row['level_text'] = "intermediate") { $page = "intermediate.php?id="; } elseif ($row['level_text'] = "high_intermediate") { $page = "intermediate.php?id="; } if ($tdcount == 1) $content .= "<li><div> <a href=\"$page" . $row['id'] ."\"></a> </div></li>"; }
  15. You are right -- fortunately this is a completely isolated incident. I got around it by moving the "favorite" processing script to a separate success page, which is working well (no random inserts) without sacrificing user experience. I really appreciate the help, and took as advice to try a different way. Thanks again, Ryan
×
×
  • 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.