PlagueInfected
Members-
Posts
75 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
PlagueInfected's Achievements
Member (2/5)
0
Reputation
-
thanks That did it for me, I knew I missed something when it came to calling. {myvar} never knew that was it to do it.
-
I don't know what I'm doing wrong here. I'm trying to do a method to where if id=2 than the db will select the articleid from the table, than load articleid2's contents. so if I call this URL http://mysite.com/articles.php?id=1 it will load article 1 than if I call this URL http://mysite.com/articles.php?id=2 it will load article 2 Here's my form code <fieldset> <legend>Adding KB article on <?php echo date("l, F d, Y");?> on <?php echo $_SERVER['HTTP_HOST']; ?></legend> <form action="../admin/knowledge_base.php" method="POST"> <input type="hidden" name="date" value="<?php echo date("l, F d, Y"); ?>" border="0" /> <label>Article ID</label> <input type="text" name="articleid" /> <br /> <?php $connect = mysql_connect("localhost", "myusername", "mypassword") or die ('Error:' .mysql_error()); if (!$connect) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydatabse", $connect); $query = "SELECT articleid, COUNT(articleid) FROM knowledge_base"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are currently " . $row['COUNT(articleid)'] ." article(s)" . "\n"; if ($row['COUNT(articleid)'] == "0") { $row['COUNT(articleid)'] = "0"; } } ?> <br /> <label> Article Name</label> <input type="text" name="articlename" id="admin_subject" /> <br /> <label>Article Information </label><br /> <textarea name="articleinfo" id="admin_textarea"></textarea> <br /> <input type="submit" value="submit" /> <input type="reset" value="reset" /> </form> </fieldset> here is my write code <?php $articleid = $_POST['id']; $articlename = $_POST['articlename']; $articleinfo = $_POST['articleinfo']; $date = $_POST['date']; $error = "no content inserted on update page"; //if not content is plugged in echo error if (!$articlename && !$articleinfo) { echo "Error: " . $error . "\n"; } //MySQL connection $connect = mysql_connect("localhost", "myusername", "mypassword") or die ('Error:' .mysql_error()); if (!$connect) { die('Could not connect: ' . mysql_error()); } if ($connect && !$articlename && !$articleinfo &&!$articleid) { die ('No information submitted to post to DB'); } mysql_select_db("mydatabse", $connect); //Created MySQL 'knowledge_base' table $sql = "CREATE TABLE knowledge_base ( articleid(4), articlename(20), articleinfo(2000), date(20), )"; mysql_query($sql,$connect); mysql_query("INSERT INTO knowledge_base (articleid,articlename, articleinfo, date) VALUES ('$articleid', '$articlename', '$articleinfo', '$date')"); echo "Article published on " . $date . "\r\n" . ' <a href="javascript:history.back(-2);">Click to go back!</a>'; mysql_close($connect); ?> and here is my calling code with the statements <?php /* Knowledge Base */ $id = $_GET['id']; $article_id_call = $row['articleid']; $connect = mysql_connect("localhost", "myusername", "mypassword"); if (!$connect) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydatabase", $connect); $result = mysql_query("SELECT articleid FROM knowledge_base"); mysql_close($connect); if ($id == $article_id_call) { $connect = mysql_connect("localhost", "myusername", "mypassword"); if (!$connect) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydatabse", $connect); $result = mysql_query("SELECT * FROM knowledge_base ORDER BY articlename"); while($row = mysql_fetch_array($result)) { echo "<h1>" . $row['articlename'] . "</h1>" . "\n"; echo " <div id='base'>" . $row['articleinfo'] . "</div>" . "\n"; } mysql_close($connect); } elseif ($id == !$article_id_call) { echo "this article does not exist!"; } else { echo "knowledge base test."; } ?>
-
PHP get images filename...not working
PlagueInfected replied to PlagueInfected's topic in PHP Coding Help
ace got it to work, for some reason now the URL goes to... home/jpmarine/public_html/img/portfolio/velvetacidchrist.jpg anyway to only keep the filename itself? velvetacidchrist.jpg -
PHP get images filename...not working
PlagueInfected replied to PlagueInfected's topic in PHP Coding Help
nvm, found out how to turn it on. It isn't giving me any message or anything. and I can't a single output =/ I'm using hostgator as my host? would how they structure the files have something to do with it. -
PHP get images filename...not working
PlagueInfected replied to PlagueInfected's topic in PHP Coding Help
tbh I don't know how to turn it on, lol. Still new to PHP. for the directory path, would I need to include the full URL? -
PHP get images filename...not working
PlagueInfected replied to PlagueInfected's topic in PHP Coding Help
no output here's how I coded it. <?php // starting directory. Dot means current directory $basedir = "img/portfolio"; // function to count depth of directory function getdepth($fn){ return (($p = strpos($fn, "/")) === false) ? 0 : (1 + getdepth(substr($fn, $p+1))); } // function to print a line of html for the indented hyperlink function printlink($fn){ $indent = getdepth($fn); // get indent value echo $fn . "<br />"; } // main function that scans the directory tree for web pages function listdir($basedir){ if ($handle = @opendir($basedir)) { while (false !== ($fn = readdir($handle))){ if ($fn != '.' && $fn != '..'){ // ignore these $dir = $basedir."/".$fn; if (is_dir($dir)){ listdir($dir); // recursive call to this function } else { //only consider .html etc. files if (preg_match("/[^.\/].+\.(jpg|gif|png)$/",$dir,$fname)) { printlink($fname[0]); //generate the html code } } } } closedir($handle); } } // function call listdir($basedir); //this line starts the ball rolling ?> -
PHP get images filename...not working
PlagueInfected replied to PlagueInfected's topic in PHP Coding Help
no joy = nothing lol I got no output at all I echoed $fname and even replaced $fn with $fname and I got no output -
PHP get images filename...not working
PlagueInfected replied to PlagueInfected's topic in PHP Coding Help
just tried it,no joy -
here's what I got <?php // starting directory. Dot means current directory $basedir = "img/portfolio"; // function to count depth of directory function getdepth($fn){ return (($p = strpos($fn, "/")) === false) ? 0 : (1 + getdepth(substr($fn, $p+1))); } // function to print a line of html for the indented hyperlink function printlink($fn){ $indent = getdepth($fn); // get indent value echo "<li class=\"$indent\"><a href=\"http://plagueinfected.com/img/portfolio/$fn\"><img src=\"http://plagueinfected.com/img/portfolio/thumbnails/$fn\">"; //print url $handle = fopen($fn, "r"); //open web page file $filestr = fread($handle, 1024); //read top part of html fclose($handle); //clos web page file echo "</a><br>\n"; //finish html } // main function that scans the directory tree for web pages function listdir($basedir){ if ($handle = @opendir($basedir)) { while (false !== ($fn = readdir($handle))){ if ($fn != '.' && $fn != '..'){ // ignore these $dir = $basedir."/".$fn; if (is_dir($dir)){ listdir($dir); // recursive call to this function } else { //only consider .html etc. files if (preg_match("/[^.\/].+\.(jpg|gif|png)$/",$dir,$fname)) { printlink($fname[0]); //generate the html code } } } } closedir($handle); } } // function call listdir($basedir); //this line starts the ball rolling ?> Any ideas?
-
better take a suppository, it worked! thanks dude, been trying to code one for some time, damn this helps.
-
it's missing 2 arguments, I don't know what I'm missing http://plagueinfected.com/sitemap.php <?php function recursive_scan($basedir='./',$extension='php',$ignore=array('.','..','inc', 'services', 'editor', 'monavie', 'music')) { if(file_exists($basedir) && is_dir($basedir)) { $basedir = substr($basedir,-1) != '/' ? $basedir . '/' : $basedir; $list_tmp = glob($basedir . '*'); foreach($list_tmp as $key => $value) { if(!in_array(pathinfo($value,PATHINFO_FILENAME),$ignore)) { if(is_dir($value)) { $files = recursive_scan($value,$extension,$ignore); if(count($files) > 0) { $list[$key]['name'] = $value; $list[$key]['files'] = $files; } } elseif(pathinfo($value,PATHINFO_EXTENSION) == $extension) { $list[$key]['name'] = $value; } } } return $list; } else { return FALSE; } } function get_links($file_array,$baselink) { foreach($file_array as $key => $value) { if(!isset($value['files'])) { $file_name = substr($value['name'],0,1) == '.' ? substr($value['name'],1) : $value['name']; $file_name = substr($file_name,0,1) == '/' ? $file_name : '/' . $file_name; $links[] = $baselink . $file_name . "\r\n"; print_r($links); } else { foreach(get_links($value['files']) as $file) { $links[] = $baselink . $file; } } } return $links; } print_r(get_links(recursive_scan(),'http://www.plagueinfected.com')); ?>
-
yup
-
didn't work =/
-
here man, check it out http://plagueinfected.com/sitemap.php
-
I tried your sitemap, and what it did was list the pages in a decoded array