
vynsane
Members-
Posts
66 -
Joined
-
Last visited
Everything posted by vynsane
-
most that i know of will require JavaScript, but i've been happy with FCKeditor http://www.fckeditor.net/
-
right, i understand why it's happening, i need to get around the "pickiness" or "limitations" (depending on how you see it) of php4's strtotime function and figure out a way to get to what i need. i've tried variations of adding "-01" to the end of my date variable to try to fill it out into a full date, but to no avail. like this: $row['date']-01 = $fauxDate; "".$row['date']."-01" = $fauxDate; and so on, but it's not working...
-
i'm trying to create a list of distinct months where there are archived entries to a blog. it works on my localhost under php5, but it doesn't under php4 because the strtotime function won't understand that mysql is pulling a date in a different format. here is the sql statement: SELECT DISTINCT DATE_FORMAT(submitDate,'%Y-%m') AS date FROM table WHERE archived = 'y' ORDER BY date DESC and the function that i'm tring to use to turn that into a different format function monthYear($submitDate) { $formattedDate = date("F Y", strtotime($submitDate)); return "$formattedDate"; } in php5, i get a list that consists of September 2007 August 2007 (which is correct, i only have two months with archived entries) but in php4 i get December 1969 December 1969 the reason why i'm using the date_format is because i need to transform it into two different forms - the kind above, and also into 09-2007 and 08-2007 for the actual url in the link. basically two functions turn the date_format version into this link: <a href="/archive:09-2007/">September 2007</a> how can i pull only a distinct MONTH and YEAR (don't want distinct dates, because i'll get a row for each DAY) and then turn that into the two desired formats in php4? i've tried tacking on a "-01" to the date to fool php4 into thinking that it's a full legitimate date, but that only freaks it out more. perhaps i'm just not adding it correctly...
-
not a rule by the slightest, but if you need to get an absolute url path relative to a domain name that isn't pointing to the doc root, then $_SERVER['DOCUMENT_ROOT'] won't work for what you need. i use it on my site to create absolute url's on a site that has three separate domain aliases that point to a subfolder of my doc root. i now see that it wouldn't apply in this case - i guess i was too groggy when i posted. anyway, i first discovered it in this thread: http://www.phpfreaks.com/forums/index.php/topic,129379.msg541897.html#msg541897
-
just for the info, that only works if your domain name IS in the doc root of the server. for purposes of those using domain pointers that go to a sub-folder of the doc root, this works as well: $_SERVER['HTTP_HOST']
-
[SOLVED] RSS Feed creator problem - not valid RSS feed?
vynsane replied to vynsane's topic in PHP Coding Help
hrm, yeah... i should'a thought of that. fixed! changed the address, too: www.WallCrawlersWeb.com/news/feed.rss -
i've been working on a script that would generate an RSS feed, and that seems to work, it displays the feed in FireFox the way it should, but when i try to link to it as a live bookmark or aggregate it in thunderbird, it claims it to not be a valid feed. here's the feed: http://www.wallcrawlersweb.com/news/feed/news.rss and here's the script that generates it: $fp = fopen ("news.rss", "w"); fwrite ($fp, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"); fwrite ($fp, "\t<rss version=\"2.0\">\n"); fwrite ($fp, "\t\t<channel>\n"); fwrite ($fp, "\t\t\t<title>WallCrawlersWeb.com - Spider-man News</title>\n"); fwrite ($fp, "\t\t\t<link>http://www.WallCrawlersWeb.com/news/</link>\n"); fwrite ($fp, "\t\t\t<description>News from all aspects of Spider-man collecting: Comics, Movies, Toys, Collectibles, Television, Video Games</description>\n"); fwrite ($fp, "\t\t\t<language>en-us</language>\n"); fwrite ($fp, "\t\t\t<docs>http://www.WallCrawlersWeb.com/news/feed/news.rss</docs>\n"); (database connection deleted) $newsQuery = "SELECT Members.username, NewsCat.catName, NewsItem.* FROM Members, NewsCat, NewsItem WHERE NewsItem.category = NewsCat.ID AND Members.id = NewsItem.Members_id ORDER BY NewsItem.id DESC"; $newsobject = mysql_query($newsQuery) or die(mysql_error()); while ($row = mysql_fetch_array($newsobject)) { $newsCat = $row['catName']; $title = stripslashes($row['title']); $teaser = stripslashes($row['preview']); $ID = $row['id']; $username = $row['username']; fwrite ($fp, "\t\t\t<item>\n"); fwrite ($fp, "\t\t\t\t<title>$newsCat: $title</title>\n"); fwrite ($fp, "\t\t\t\t<description>$teaser</description>\n"); fwrite ($fp, "\t\t\t\t<link>http://www.WallCrawlersWeb.com/news/article/$ID</link>\n"); fwrite ($fp, "\t\t\t</item>\n"); } fwrite ($fp, "\t\t</channel>\n"); fwrite ($fp, "\t</rss>\n"); fclose ($fp); is there something wrong in my script? should i get rid of the tab and newline regexes?
-
HOLY CRAP! now THAT's some CODIN'! that did it, thanks sasa! i think i'll try to turn that into a function though, in order to cut down on the code on the page. and thanks to everyone else that brain stormed with me. i hope your headaches go away as fast as mine does.
-
as i suspected, this gives me commas at the end of every name, but it's the closest i've gotten yet. this would easily work if the only things in the array were the Fname, Lname and suffix, but i've got a whole lot of other stuff in there as well. i might have to resort to multiple queries to break down the info into bite-size chunks. easier to swallow that way.
-
interesting method... before you made the edit to "hang on" i was going to say it would probably end up with a comma on the end of everything though: Editor: Len Wein, Writer: Gerry Conway, Penciller: Ross Andru, Inker: Mike Esposito, David Hunt, i guess i would only build the string like this after doing a numrows count and finding out if it's necessary - this would also get me to add the "s" after "Inker" so two birds with one stone. otherwise just straight-up echo. i'll experiment with this, thanks! i only need to add a comma if there are multiple names for each job, so Editor: Len Wein needn't a comma, whereas Inker: Mike Esposito David Hunt does, after "Esposito". but unfortunately i have the "suffix" as well, so i can't just automatically place the comma after the last name.
-
i love one-word answers, that's awesome. always a lot of fun. as stated above, i've already tried using "join()" which is an alias of "implode()". this doesn't work since the first name, last name and suffix are each independent nodes of the array containing them (since they're in separate columns, Fname, Lname and suffix), and thus will end up with something like this: Inker: Mike, Esposito, David, Hunt whereas i need it to look like this: Inker: Mike Esposito, David Hunt (i also would like it to say "Inkers:" instead of "Inker:" when there's multiple names for that job, but that's not the huge issue... and i can probably figure that one out on my own... but maybe not. probably will just have to make another query inside the "foreach" that checks numrows for multiples of that ID number and echo accordingly.) i suppose i could use either "join()" or "implode()" if i could turn the first, last, and suffix into a string, then for each job make a new array out of the strings THEN implode but that seems pretty long-winded.
-
i've got a script that pulls first name, last name, and suffix from a DB query and echos them only if they are not null. the names are cross-referenced by id number from two other tables. it displays the name pieces that are not null for each "job", and the jobs and names are determined by another id number for an individual issue page. an example of the output is here: www.WallCrawlersWeb.com/database/comics/title/asm/issue/148/creative as you can see, the job "inker" has two names after it. how can i get it to put a comma between those two names. this is the bit that writes that box: $creatorQuery = mysql_query("SELECT * FROM ComicCreators, Creators, CreatorCat WHERE ComicCreators.issueID = '".$ComicIssues['ID']."' AND ComicCreators.creatorID = Creators.ID AND ComicCreators.creatorCatID = CreatorCat.ID ORDER BY CreatorCat.ID"); $creatorNumRows = mysql_num_rows($creatorQuery); if($creatorNumRows > 0) { while($row = mysql_fetch_array($creatorQuery)){ $creators[$row['catName']][] = $row; } foreach($creators as $creatorCat => $creators) { echo "<p><strong>".$creatorCat.":</strong>"; foreach($creators as $creator){ if($creator['Fname'] !=Null){ echo " ".$creator['Fname'].""; } if($creator['Lname'] !=Null){ echo " ".$creator['Lname'].""; } if($creator['suffix'] !=Null){ echo " ".$creator['suffix'].""; } } echo "</p>\n"; } } else { echo "\t\t\t\t\t<p>No creative team information available.</p>\n"; } i've tried using join() but it only works if it's an array, and by the time i've echoed or stringed the name based on what is not null, it's not an array anymore. i've also tried using rtrim() but it gets rid of all commas, because each name is rtrim()ed. anyone got a good solution?
-
[SOLVED] repeat form field based on $_POST data
vynsane replied to vynsane's topic in PHP Coding Help
that was close enough to get me on the right track... awesomeness, thanks! what i ended up doing was use the "str_repeat()" function to display each "job" multiplied by the $_POSTed $qty, and modified your "creator selector" function to suit my needs (i needed to place the commas the correct way, so i had to do it with a couple of "if" statements instead of the way you did it... this is what i came up with: foreach ($_POST['qty'] as $k => $qty) { $catID = $_POST['catID'][$k]; if($qty !=='0') { $jobsQuery = mysql_query("SELECT * FROM Categories WHERE ID = '".$catID."'"); while ($jobs = mysql_fetch_array($jobsQuery)){ $str = "<tr>\n"; $str .= "<td class=\"textright\"><strong>".$jobs['catName'].":</strong><input type=\"hidden\" name=\"catID[]\" value=\"".$jobs['ID']."\" /></td>\n"; $str .= "<td>\n"; $str .= creatorSelect(); $str .= "</select>\n"; $str .= "</td>\n"; $str .= "</tr>\n"; echo "".str_repeat($str, $qty).""; } } } the echo of the str_repeat() function was able to repeat the $str multiplied by the $qty, ending up with my desired result. and the modified select function: // creator select routine function creatorSelect() { $creatorsQuery = mysql_query("SELECT ID, Lname, Fname, suffix FROM names ORDER BY Lname"); $str = "<select name=\"creatorID[]\">\n"; $str .= "<option value=\"0\">Choose</option>\n"; while($creators = mysql_fetch_array($creatorsQuery)) { $str .= "<option value=\"".$creators['ID']."\">"; if($creators['Lname'] !=Null){ $str .= "".$creators['Lname'].", "; } if($creators['Fname'] !=Null){ $str .= "".$creators['Fname'].""; } if($creators['suffix'] !=Null){ $str .= ", ".$creators['suffix'].""; } $str .= "</option>\n"; } $str .= "</select>"; return $str; } // -
[SOLVED] repeat form field based on $_POST data
vynsane replied to vynsane's topic in PHP Coding Help
could i use the function str_repeat() to do this? that might work... -
[SOLVED] repeat form field based on $_POST data
vynsane replied to vynsane's topic in PHP Coding Help
i need to keep the catID as a hidden input because there's a third step to the form that inserts it into the database. the method you posed does not answer my problem, maybe i'm not making it as clear as it could be... it's pretty complex, so it's hard to describe. the first step of the form is to setup the quantity of each category i need, the second step is to choose the name of the person for each category, and the third step is to the submit the category id and the person's id into the database along with other hidden fields like the user's id that's submitting it and the current date as submission date. i have the first and third step working, the second step is missing a vital ability, which is to display each category with a select box of names next to it based on the quantity posted by the first step - for instance, if "inker" is posted from the initial form as "2" i need to display the "inker" category and select box twice. that's what i need help figuring out, how to display those two items multiple times based on the $qty variable posted from the initial form. -
i have a script that sets up a second page with multiple select boxes. the first script has a hidden field for the ID number, and a text input field for quantity. the second part of the script has a foreach loop that gets the info that goes with the ID number and then creates the select box next to it. for the most part it's all working correctly, but i don't know how to get the submitted "quantity" to repeat that ID number (and everything else). here is the initial form: <table> <tr> <td class="textright">How many <strong>Editors:</strong><input type="hidden" name="catID[]" value="1" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Plots:</strong><input type="hidden" name="catID[]" value="2" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Scripts:</strong><input type="hidden" name="catID[]" value="3" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Writers:</strong><input type="hidden" name="catID[]" value="4" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Artists:</strong><input type="hidden" name="catID[]" value="5" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Pencillers:</strong><input type="hidden" name="catID[]" value="6" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Inkers:</strong><input type="hidden" name="catID[]" value="7" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Cover Arts:</strong><input type="hidden" name="catID[]" value="8" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> <tr> <td class="textright">How many <strong>Additional Arts:</strong><input type="hidden" name="catID[]" value="9" /></td> <td> <input type="text" style="width:30px;" name="qty[]" value="0" /> </td> </tr> </table> this gives me an array like this: Array ( ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 ) [qty] => Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 2 [4] => 0 [5] => 2 [6] => 0 [7] => 1 [8] => 0 ) [next] => Next ) the php code on the second step of the form is the foreach loop to spit out the jobs and select boxes: foreach ($_POST['qty'] as $k => $qty) { $catID = $_POST['catID'][$k]; if($qty !=='0') { $jobsQuery = mysql_query("SELECT * FROM Category WHERE ID = '".$catID."'"); while ($jobs = mysql_fetch_array($jobsQuery)){ echo "<tr>\n"; echo "<td class=\"textright\"><strong>".$jobs['category'].":</strong><input type=\"hidden\" name=\"catID[]\" value=\"".$jobs['ID']."\" /></td>\n"; echo "<td>\n"; echo "<select name=\"creatorID[]\">\n"; echo "<option selected=\"selected\" value=\"0\">Choose</option>\n"; $creatorsQuery = mysql_query("SELECT * FROM names ORDER BY Lname"); while($creators = mysql_fetch_array($creatorsQuery)){ echo "<option value=\"".$creators['ID']."\">"; if($creators['Lname'] !=Null){ echo "".$creators['Lname'].", "; } if($creators['Fname'] !=Null){ echo "".$creators['Fname'].""; } if($creators['suffix'] !=Null){ echo ", ".$creators['suffix'].""; } echo "</option>\n"; } echo "</select>\n"; echo "</td>\n"; echo "</tr>\n"; } } } this outputs only the fields that were not "$qty=0" like below: <table> <tr> <td class="textright"><strong>Editor:</strong><input type="hidden" name="catID[]" value="1" /></td> <td> <select name="creatorID[]"> <option selected="selected" value="0">Choose</option> <option value="67">Paty</option> <option value="282">Studio F</option> <option value="296">Dream Engine</option> <option value="182">Abel, Jack</option> </select> </td> </tr> <tr> <td class="textright"><strong>Writer:</strong><input type="hidden" name="catID[]" value="4" /></td> <td> <select name="creatorID[]"> <option selected="selected" value="0">Choose</option> <option value="67">Paty</option> <option value="282">Studio F</option> <option value="296">Dream Engine</option> <option value="182">Abel, Jack</option> </select> </td> </tr> <tr> <td class="textright"><strong>Penciller:</strong><input type="hidden" name="catID[]" value="6" /></td> <td> <select name="creatorID[]"> <option selected="selected" value="0">Choose</option> <option value="67">Paty</option> <option value="282">Studio F</option> <option value="296">Dream Engine</option> <option value="182">Abel, Jack</option> </select> </td> </tr> <tr> <td class="textright"><strong>Cover Art:</strong><input type="hidden" name="catID[]" value="8" /></td> <td> <select name="creatorID[]"> <option selected="selected" value="0">Choose</option> <option value="67">Paty</option> <option value="282">Studio F</option> <option value="296">Dream Engine</option> <option value="182">Abel, Jack</option> </select> </td> </tr> </table> BUT it's not repeating each field based on the $qty number. that's what i need to do. is there a way i can edit the existing code to get this to work?
-
do you need to have it working on windows before you put it on the server? and what OS is your server? if it's a linux/unix server, and you're not trying to test it on your local machine first, you can upload it and rename it on the server. if you need to test, upload it to a new folder on the server so it doesn't mess anything up, rename it, and then download the renamed version. also, what program are you using to write the .htaccess file? i was able to save the file correctly using araneae: www.ornj.net/araneae/
-
just FYI, i solved my own problem at the end of my post - that's what i did - i turned the forms into POST instead of GET and created a passthrough script that redirects to the correct URL. it's actually a cool little technique and i made it a multi-purpose page so at the moment 5 different forms are using the passthrough.
-
hi, all... i'm wondering if there's a way to send $_GET variables to a page in the same form as the mod_rewrite rules that i'm using. for example, this page: http://invincible.comics-database.com/database/comicsByReleaseDate/01-2006 is really this: http://invincible.comics-database.com/database/comicsByReleaseDate.php?month=01&year=2006 the form is on this page (under "search by release date"): http://invincible.comics-database.com/database/ the form sends one select as the month and one select as the year. basically the question is: how can i take $_GET variables coming from that form ("month=01" and "year=2006") and turn it into the mod-rewrite emulated folder structure ("/01-2006")? is there a mod_rewrite that can be done, or would i have to pass it through another script that transforms the $_GETs into the form i need and then redirect it to the proper version of the URL?
-
at the top of the page, if you put if(header("Location: http://www.yourURL.com/yourform")) { header("Location:https://www.yourURL.com/yourform"); } not tested, not sure, but that might work, or put you on the right path...
-
[SOLVED] call function in middle of a variable?
vynsane replied to vynsane's topic in PHP Coding Help
Yeah, I'm going to look into that, too. Found an even better way to do it than $pageTitle = "Spider-man Comics ".comicTitle($ComicTable['title'], $Vol)." Issue $IssueNum"; since I have to use it multiple times, with "return" I can turn the function into a variable, and call that variable elsewhere: $comicTitle = comicTitle($ComicTable['title'], $Vol); $pageTitle = "Spider-man Comics $comicTitle Issue $IssueNum"; ... .... .... ... echo "<div class=\"header\">$comicTitle Issue $Issue</div>\n"; Thanks again! -
[SOLVED] call function in middle of a variable?
vynsane replied to vynsane's topic in PHP Coding Help
huh... weird, when i tried that before, it didn't work, but now it is. function comicTitle($fulltitle, $volNum) { $query = mysql_query("SELECT title FROM ComicTable WHERE title = '".$fulltitle."'"); $rows = mysql_num_rows($query); $Title = stripslashes($fulltitle); if($rows >1) { $comicFullTitle = "$Title Vol. $volNum"; } else { $comicFullTitle = "$Title"; } return $comicFullTitle; } I think I had $comicFullTitle = "".$Title." Vol. ".$volNum.""; instead... that might've been the culprit. now I just have to go back to everywhere else I use that function and change it to use the return instead of the echo :'( :-\ -
[SOLVED] call function in middle of a variable?
vynsane replied to vynsane's topic in PHP Coding Help
Thanks for the quick reply, but that doesn't work - it just spits out the function before everything else on the page, doesn't contain it inside the variable "$pageTitle". -
I'm migrating to a pseudo-template system (header/footer includes) and have created a variable that will send the title of that page to the <title> in the header include. The problem I'm facing is that some of my pages had functions in the title tag, and I'm having a problem getting the function into the new variable. An example of the code prior would've been: <title>Spider-man Comics <?php comicTitle($ComicTable['title'], $Vol); echo "Issue $IssueNum"; ?></title> the function looks something like this: function comicTitle($fulltitle, $volNum) { $query = mysql_query("SELECT title FROM ComicTable WHERE title = '".$fulltitle."'"); $rows = mysql_num_rows($query); $Title = stripslashes($fulltitle); echo "$Title"; if($rows >1) { echo " Vol. ".$volNum.""; } } What I would like to be able to do on my other page (the function is in an include) is something like this: $pageTitle = "Spider-man Comics" comicTitle($ComicTable['title'], $Vol); "Issue $IssueNum"; but that's obviously not working... I've tried variations of the $pageTitle variable, and variations on the comicTitle function, including using "compact()" and "extract()" or just trying to string my two variables ($Title and $Vol) into one variable and returning that one variable, but it's not working. Any help would be much appreciated.