Jump to content

The14thGOD

Members
  • Posts

    256
  • Joined

  • Last visited

    Never

Everything posted by The14thGOD

  1. Just briefly looked this over, but <?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>"; ?> Value has single quotes around the double quotes. Shouldnt it be: <?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value=\"".$row['tag_name']."\"></input>"; ?>
  2. I'm new to this mod_rewrite thing so I am just messing around trying to get it to work. I managed to get it to work but there's a problem with relative paths. I wanted to create something that could be very dynamic (meaning I can just drop this anywhere and it'll work with unlimited number of /paths/to/a/document/like/this vs /this/path/). Now, short of using absolute links to the files, this is what I came up with: <?php $thispage = explode('/',substr($_SERVER['PHP_SELF'],0,-4)); $fulluri = explode('/',$_SERVER['REQUEST_URI']); $num = sizeof($fulluri) - sizeof($thispage); for($i=0;$i<$num;$i++){ $pathback.= '../'; }?> The above $pathback is then used in code like: <?php $hash["$row[sub_category]"][]= "<a href=\"".$pathback."image_details.php?id=$row[id]\"><img class=\"galleryimg\" src=\"".$pathback.$row['thumbnail']."\" $dims alt=\"$row[title] thumbnail\" title=\"$row[title]\" /></a> \n"; ?> I'm trying to get into the habit of using more efficient code but when in unfamiliar territory that doesn't usually work. Anyone got any ideas or suggestions to make this work better? Also, sorry for doing this but I've been waiting in response and it's sort of relative to this anyways: From: http://www.phpfreaks.com/forums/index.php/topic,257882.0.html Any help would be greatly appreciated. Justin
  3. This is my first attempt at getting mod_rewrite to work so sorry for the noob questions, i have several links for regular expressions etc and im comming up with blanks hah. anyways, i have it to the point where it rewrites the url but if an invalid url is put in it's not redirecting to the right file: RewriteEngine On RewriteRule ^gallery/category/([a-z]+)/ gallery.php?category=$1 RewriteRule ^gallery/category$ ../../../index.php I think it ignores the ../ cause it's still going to the same page if they were not there. The second issue I am having is I want to make the page so it's more dynamic, meaning depending on the variables in the URL i dont have to go to the page and add "../../../...." to each link. How do I make these links relative off of the rewrite and not the visible URL? IE: <?php $hash["$row[sub_category]"][]= "<a href=\"../../../image_details.php?id=$row[id]\"><img class=\"galleryimg\" src=\"../../../$row[thumbnail]\" $dims alt=\"$row[title] thumbnail\" title=\"$row[title]\" /></a> \n";?> or <link rel="stylesheet" type="text/css" href="../../../css/styles.css" /> Thanks for any and all help, again sorry for the probably easy questions Jusitn
  4. ah, thanks! i really need to sit down and get my head wrapped around these, i have good links, just not to time
  5. thank you ken for the fix and thank you crayon for explaining it, though I'm a little confused about the 'i' at the end... again, thanks for the help!
  6. Error: Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in index.php on line 377 Hmm, when i leave them unescaped i get the same characters at the start and end of the string. so basically it looks like: < $image01<strong>$row[display_date]</strong> - > I assumed it just replaced the letter p.
  7. I've looked for a while and cant seem to find how to escape < and > out of my regular expression. <?php $row['body'] = preg_replace("\<p\>","<p>$image01<strong>$row[display_date]</strong> - ",$row['body'],1);?> I've tried single '\' and i get an error and i've tried double \\. Obviously I don't know much about reg expressions, sorry. I rarely use them and when I do it's usually copy/paste for URLs and Emails.
  8. thanks for responding BobcatM. However, that is not what I want =O I managed to get it though after throwing 2 snippets together it was just sitting there. Here it is for anyone who might have the problem later on: <?php $query = "SELECT * FROM news WHERE id=$_GET[id] LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); foreach($row as $var => $value) { ${$var} = $value; } ?>
  9. I have no idea how to look this up so any tips are much appreciated. I want to take an array from a database ($row in this case) and keep the associative name as a variable. I'm making 1 page that inserts/updates/deletes a blog entries. So instead of adding a crap ton of if's/echo's for new variables (eg $row['body']) I figured it would be better (less lines of code) to make $row['body'] into $body. Any ideas? I've never been great with arrays so sorry if this is a really easy question. My first idea was to use explode('[') and then I remember vaguely (trying to track it down right now) a method to make text into a new variable using ${} or something. Thanks again, Justin
  10. I'm going to show my real newbness here to PHP Security, what do you mean by 'signing" the contents of the file?
  11. I've come back to start digging into security for PHP and I was reading up on salt methods etc when I noticed there were lots of mixed thoughts on which hash to use. I eventually came to: http://www.php.net/manual/en/function.hash.php#89574 I know it kind of depends on the site but which is generally the most secure? Is/are md5/sha1 basically outdated? Thanks for any and all help clearing this up! Justin
  12. I didn't know I could do that in the query. The main concern though is getting the content to flow in 2 columns well. So it reaches close to the end of column rather than 1 word on a new line and then jumping to the next column. Here's an image demonstrating what I mean: http://the14thgod.com/misc/2columns.jpg On a side note If you don't mind could you provide an example of how to do that in the query? Would be great for future reference =D Thanks, Justin
  13. First off, I'm not sure where to put this but I think it belongs more so here than in any of the other forums. I've built a website using PHP and MySQL as the back-end and the firm designed the stories into 2 columns. The problem I'm having is how to display it nicely. There are 2 ways it is displayed. On the home page only about 130ish words are displayed (followed by a read more button). I originally set it up so it would put X amount of words in column 1 and then the rest in column 2. However there is a story that has 1 word on a new line and then the words start up at the top of the next column. On the page that corresponds to the story itself I just basically cut the article in half. Here's the code: <?php $words = explode(' ',$row['body']); for($i=0;$i<84;$i++) { $td1 .= $words[$i]." "; } for($i=84;$i<134;$i++) { $td2 .= $words[$i]." "; } echo "<td><p>$td1</p></td>\n"; echo "<td><p>$td2</p>\n"; ?> This is just the code for the home page that displays the first 134 words. The code for the other pages is basically the same. Anyone have any ideas? Thanks for any and all help, Justin
  14. Basically I am using PHP to validate a form and if the user has to go back it makes a bunch of $_SESSION variables and stores what the user put in. Now it stores it and repopulates the form correctly the 1st time. However, if I go in and change things and still "make a mistake" it keeps the old data. It doesn't overwrite. IE If I had a name field and changed it from John to Joe it would stay as John when it comes back saying I missed something yet again. Here's the code that I'm using to set and overwrite the variables (they're more variables but its the same thing so I took them out) <?php import_request_variables('pg'); if($format == 1) { //stuff }else { session_start(); $_SESSION['category'] = $category; $_SESSION['format'] = $format; $_SESSION['homepage'] = $homepage; header("Location: index.php?error=format"); exit(0); } ?> Basically if I dont enter anything into format it shoots back telling me I have to select something for format. So if I miss something again and I ended up changing a bunch of things, it doesnt change. It keeps the old values I put in. This may not be the most efficient way but it's the quickest way I know (on a budget). It works on my server for my website but doesn't work on this server Im testing on. Is there a global php setting that I need to enable/set? Thanks for any and all help, Justin
  15. ah, that did not work, however you showed me i was way over complicating things! and got it to work via a different method though similar. ty =D justin
  16. Working on a project right now and this appears to not be working... <?php for($i=1;$i<9;$i++) { $linkage = ${'project_row[img'.$i.'thumb]'}; echo $linkage; //if($linkage != "") { //echo "<a href=\"see.php?project=$_GET[project]&img=$i\"><img class=\"thumbs\" src=\"$linkage\" width=\"62\" height=\"62\" alt=\"$project_row[title] thumbnail $i\" /></a>"; //} } ?> I've used similar code to combine a text and a variable to form 1 variable...so I didn't think another string added onto it would be troublesome. All help is much appreciated it's not echoing anything and the variable does exist. justin
  17. yep that worked. i don't know why though. i tried it earlier and it gave me an error regarding the function. i might have just mistyped something. ty all justin
  18. ah, it got the full name however it still put it in the same directory as the script. it didn't go back out and into the images folder.
  19. I'm trying to create a directory if the user needs to create a new category for something. I looked here: http://www.php.net/manual/en/function.mkdir.php and I still can't seem to get it to work. I've got this right now: <?php if($newcategory) { mkdir("..\images\$newcategory",0777); $uploaddir = "../images/$newcategory/";?> It just created the directory "..\images$newcategory" in the same folder as the script. I'm guessing that the \ in front of the $ is just making it ignore the variable so it's not parsing it. Anyone know how to make the directory so it goes back one folder? The server is using PHP 4.4.4 if that helps and running on Linux. Thanks for any help. Justin
  20. Ah, alright. I swear I've used that same code before though... ha. Oh well. Conker87, I tried that already, I noticed that wasn't right and changed it but for the reason Boom.dk said it didn't work. Thanks again, I'd hit the topic solved button but I can never find the damn thing. I found it once...haha
  21. Awesome, that worked rhodesa. Thank you =D I also tried conker87's way but that did not work but I appreciate the help. Thank you both for helping
  22. I can't seem to find the mistake in this code: <?php $com_query = "SELECT * FROM comments WHERE picID='$_GET[id]' AND status='enabled' "; $com_result = mysql_query($com_query); if(!mysql_query($com_query)) { echo "<p class=\"nocomments\">There are no comments yet.</p>"; }?> It's not echoing hi, it appears to not be getting inside that if statement. That reads if no mysql_query (meaning query returned nothing) then do this right? or have i been gone from php that long...hah Thanks in advance Justin
  23. Alright, that clears up some of it, like I said I'm new to functions and I appreciate the help. I've run into a problem displaying the image, here's some examples of what I've tried <?php include("includes/flip_image.php"); $image = "images/sideimgs/side02.jpg"; imageflip("images/sideimgs/side02.jpg",HORIZONTAL); //imageflip($image,HORIZONTAL); ?> <img class="rightimg" src="<?= $flipped ?>" width="154" height="768" alt="Side Image" /> I've also tried putting 1 line into where the $flipped is, so $flipped = imageflip($image,HORIZONTAL). Nothing shows up in the code when i look at the source, it looks like src="". Again, ty for the help.
  24. What? I don't understand how I choose vert/horizontal...it says if mode & vert then do this, but...the only 2 arguments are image and mode...
  25. I'm trying to figure out how to make this function work, I'm not as familiar with functions and this function doesn't seem to have anything more to explain it. I found it here: http://www.php.net/manual/en/ref.image.php#62029 <?php // This is a correction to the image-flipping function I posted previously. // The bitwise ands (&) were incorrectly written as logical ands (&&). // Needless to say, that breaks the function in obnoxious--if amusing--ways. define("VERTICAL", 1); define("HORIZONTAL", 2); function imageflip($image, $mode) { $w = imagesx($image); $h = imagesy($image); $flipped = imagecreate($w, $h); if ($mode & VERTICAL) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $image , 0, $y, 0, $h - $y - 1, $w, 1); } } if ($mode & HORIZONTAL) { for ($x = 0; $x < $w; $x++) { imagecopy($flipped, $image , $x, 0, $w - $x - 1, 0, 1, $h); } } return $flipped; } ?> I've called the function before and put the image location into where image is but I'm confused on the mode. Anyone familiar with this? Any help would be great, thanks in advance. Justin
×
×
  • 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.