Jump to content

computermax2328

Members
  • Posts

    281
  • Joined

  • Last visited

Everything posted by computermax2328

  1. The only reason I want to store it as a file on the database is to have a secondary backup. It can't hurt. I will probably stick with medium text. It seems like the best idea without overkill. Just looking for some input.
  2. Hello Everyone, I was wondering what the best practice would be for storing a blog article. I am currently building a blog and I was just wondering what technique everyone used. All I did was simple store it in a MYSQL Database as a long text. I was also thinking about storing it in a folder somewhere as well. What do you think??
  3. Yeah that was a typo. I solved it. I will mark it so
  4. Alright, so I did some tests, var_dumb, num_rows and some !if statements, and I found that the query is what is incorrect. The $_GET variable is coming down, but the query is not working. It stops at the fetch_array.
  5. Your problem is that you end your foreach before you even start it. foreach (blah blah blah) {?> That is way wrong! What you want is something like this foreach (something happens) { do something here } You wanna include your list in the the do something here
  6. Echoing inside the loop did not work. I echo outside the loop all the time and it works fine. I did the var_dumb and it can back null.
  7. Take a look at this really quick. I am not getting anything out of this query. All I am doing is echoing description which is saved as a text in a phpmyadmin database. 'table' is coming from the URL. The variable $table is working in other queries. $table = $_GET['table']; $issues = "SELECT * FROM issues WHERE table='$table'"; $isquery = mysql_query($issues, $connection); while ($row = mysql_fetch_array($isquery)) { $desc = $row['description']; } Thanks,
  8. $avg = "SELECT AVG(era) FROM $table"; $avgquery = mysql_query($avg, $connection); while($avgrow = mysql_fetch_array($avgquery)) { $avgera = $avgrow['AVG(era)']; } echo number_format(decimals($avgera), 3, ".", ","); Gives me -.0111523.00 decimals is a function that uses str_replace to strip the zero from the front of the decimal number.
  9. Hello Everyone, Haven't been here in a while. This looks new and cool! Anyway, I have PHP output an array of numbers as an average and that worked fine. I got the number -.0111523. Which is exactly what I want. They only problem is that I need the number to look like this -.011. I tried to use the number format command, but that did not work. Just slapped a couple of zeros onto the end. Any suggestions? Thanks in advance!
  10. Right! I have seen this before, but my greatest concern in this conversation is SEO and a site map when it comes to php stored articles in a database. In an xml sitemap it is best if you have each page posted on your sitemap. So, I guess my question is, is there a way to post to a site map everything you create a new story?
  11. Hello All, I have been trying to grasp this concept for a while, but no one has been able to explain it to me. I am currently developing a website and part of that website is a home brewed blog system. The blog build has been pretty fun, but the concept I have been trying to grasp is when it comes to blog posts generated by php, hmtl and xml. One be ball of coding fun. The way I have my blog built is on the backend the admin fills in all the information, title, author, blog entry, etc. Then that information is store in a database via a form POST script. On the blog front page the visitor will click the story link and all the information is pulled from the database based on an idea number automatically given to that blog post when it is posted to the database from the backend. Now the idea is how do I make those articles search engine friendly. I talked to some SEO experts and they told me that search engine crawlers prefer html, but I cant create all those pages without php. My idea is to ask is there anyway to create html pages with php and store them in a folder? Is there another method I am missing?? Thanks!
  12. What is the best way to date a new entry into a mysql database. I have a database and I want one of the columns to be date entered or just date, but what I want to happen is when it enters the date I just want it to enter something like 9/6/2012. Nothing with the time or anything. Thanks in advance.
  13. I fiddled around with this a little bit too. Here is a script that I use to do the same thing. if (isset($_POST['submit'])) { if ($_FILES['csv']['error'] > 0){ echo "Error: " . $_FILES['csv']['error'] . "</br>" . "You have not selected a file or there is another error."; } else { $name = $_FILES['csv']['name']; $tmp = $_FILES['csv']['tmp_name']; } if (!$_FILES['csv']['type'] == 'text/csv'){ echo "Please select a CSV File"; } else { $location = "tables/"; $location = $location . basename($_FILES['csv']['name']); move_uploaded_file($tmp, $location); } } $clear = "TRUNCATE TABLE labor"; if (mysql_query($clear)) { $sql = "LOAD DATA LOCAL INFILE '$location' INTO TABLE table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (`First Name`, `Last Name`, `Rank`)"; if (mysql_query($sql)) { header('Location: ../pages/home_DB.php'); exit; } else { echo "CSV Upload Query Failed " . mysql_error(); } } Two things to keep in mind, most importantly and I don't know if this is 100% true, but I always upload as a microsoft CSV. Mac has the ability to convert to that file format. Two, I used "LOAD DATA LOCAL INFILE," some hosts ask you to use different methods. Mine asked me to use this. Also notice in my code that I turncate the table before I insert the new one
  14. Alright, I do like to use the method I have been using. I guess I am trying to figure out how to make my code cleaner and more efficient. I feel like writing out the file path on every page is messy. Obviously, the file path is going to be different on every page. For example: <img src="images/echo $photo" or <img src="../images/echo $photo" You know what I mean? Different file paths for different level pages. Is there a way to clean up the code? I would just like to mention that I am currently teaching myself php. This is just something I picked up this past summer. I am doing pretty well, but I just like to pick more experienced coders minds.
  15. Hello All, Every coder has their method that they become comfortable with when it comes to coding scripts and functions. One function I never really got comfortable with is photos. In the past I have just uploaded the file with a form, into a designated folder and then stored the location in a mysql database, so when I would call it from the database it would look something like this. //Mysql select from database $photo = photos/picture.png <img src="../ echo '$photo'"; OBVIOUSLY, that is not proper php, but I am just trying to make a point. Does anyone suggest any other methods? I know some people use BLOB in phpmyadmin, but I have heard that it is php cardinal sin to use BLOB. Not really sure how it works either. Any suggestions???
  16. Welcome to the forum danielatunrase! Woooo Hoooo! I am not the new guy anymore. The way I would do it is with a table called "members" and a session check. The session check would look like this. <?php session_start(); if (!isset($_SESSION['username'])) { header('Location: ../pages/login.php'); } ?> For every user that doesn't have the 'username' set it will send them to a login page or the page you want to send your new users to. Of course you would have to send them to a create a membership page and script and a login page and script to use this method. If you are interested let me know and I will continue.
  17. Hello Again, In the database of the blog I am building I have a column for each article called "count." What I did on the article page is every time the id for the article is called to the page to select all of the content for that specific article the count will be selected from the database and updated plus one. The problem that I am having is that it is adding two to the count every time. The code looks something like this. <?php require("../includes/connection.php"); $id = $_GET['id']; $query = "SELECT * FROM blog WHERE id=$id"; $select = mysql_query($query); while ($row = mysql_fetch_array($select)) { $id = $row['id']; $count = $row['count']; $date = $row['Date']; $title = $row['Title']; $sub = $row['Subtitle']; $author = $row['Author']; $content = $row['Content']; $tags = $row['Tags']; } $addcount = $count+1; $update = "UPDATE blog SET count=$addcount WHERE id=$id"; $upcount = mysql_query($update); ?> Any ideas??
  18. Yeah, I just came back to say that I threw WHERE id!=$id into the MYSQL and that worked. Thanks for all of the suggestions! Can someone elaborate on a tagging system. Right now in my database I just have a column with each article that is a single word or phrase (ex. article about PHP). The way I had it and want it is single words sperated by columns (ex. php, mysql, coding languages). I was having problems selecting it. I was using LIKE, but I was not getting anything back. The only way I can think of is to make an entire database just with tags and associate each row with an article. Then have each column be a tag, so there would be a maximum of like 5 or 10 tags for each article. Is that the right idea?
  19. One thing I can think of right off of the bat is that it would select 'h' over 's' if it is not exactly a lower case 's.' That is what you are selecting, lower case 's.' But, I am with thorpe on this one right now. Post more!
  20. My coding is just so advance it's like I am coding in Ancient Aztec language or something. Hahaha!
  21. tibberous: I know I am only a noob at this PHP thing and I probably shouldn't be telling anyone how to code, but you should try the while(): endwhile; sometime. I really only use it when I need the while loop to output another language, usually HTML. It is just ALOT easier than echoing everything and adding all of the single and double quotes and escaping everything. Give it a try! You might like it ChristianF: Thank you for your suggestion. So, I googled what you said and from what I got I should be using MYSQL CHECK(). Is that correct? Will CHECK() automatically just not select that id variable? And one more thing, could you explain the separate table for tags? I am actually having trouble with my tag system. I am just using single phrases right now (ex. php story), no multiple tags separated with commas. I was using MYSQL LIKE to select them. I dont know if that is the right way to go. Again, I am new at this. Thanks again,
  22. Hello Again, I am building a blog from scratch and below the articles on the article pages I have a related articles section for obvious reasons. The way I built is to search the articles database for every article with a similar tag to the article above. The obvious problem here is that the article that is on the page already will be selected with this query. How can I go about selecting every article except for the one above? My code is below. Thanks in advance! <div id="relatedhead"> <h3 class="related">Related Articles</h3> </div> <?php $rquery = "SELECT * FROM blog WHERE Tags LIKE '%" . $tags . "%' OR '%" . $tags . "%' OR '%" . $tags . "%' OR '%" . $title . "%' OR '%" . $sub . "%'"; $rselect = mysql_query($rquery); if (!rselect) { echo "Query Not Working" . mysql_error(); } while ($rrow = mysql_fetch_array($rselect)): $rid = $rrow['id']; $rtitle = $rrow['Title']; $rsub = $rrow['Subtitle']; $rdesc = $rrow['Description']; $rauth = $rrow['Author']; $rdate = $rrow['Date']; $rtags = $rrow['Tags']; ?> <div id="related"> <div id="rtitle"> <h1 class="related"><? echo $rtitle;?></h1> </div> <div id="rsub"> <h2 class="related"><? echo $rsub;?></h2> <p3>Posted By: <?php echo $rauth;?></p3> </div> <div id="rtime"> <p2>Posted: <?php echo $rdate;?></p2></br> <p3 class="tags">Tags: <?php echo $rtags;?></p3> </div> <div id="rdesc"> <p><?php echo $rdesc;?></p> <a class="toarticle" href="article.php?id=<?php echo $rid;?>&<?php echo $rtitle;?>"><p2>Read More-></p2></a> </div> <img class="photoright" src="#"/> </div> <?php endwhile; ?>
  23. I went with the str_replace(). That was the most effective method. Thanks again,
×
×
  • 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.