Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. str_replace Read the manual. You need the str_replace(replace, replacewith, replacein) for it to work. Not just the what to replace.
  2. If you have GD library you can actually make it one image. If you would rather it be CSS, this is not a PHP question, it is an HTML/CSS question. I suggest taking it to that forum. image if you are interested in creating the image as one.
  3. I did not really mean for you to actually implement the whole script. More of use it as a guideline, particulary the display part. <?php // just so we know it is broken error_reporting(E_ALL); // some basic sanity checks if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) { //connect to the db $link = mysql_connect("localhost", "username", "password") or die("Could not connect: " . mysql_error()); // select our database mysql_select_db("testblob") or die(mysql_error()); // get the image from the db $sql = "SELECT image FROM testblob WHERE image_id=0"; // the result of the query $result = mysql_query("$sql") or die("Invalid query: " . mysql_error()); // set the header for the image header("Content-type: image/jpeg"); echo mysql_result($result, 0); } else { echo 'Please use a real id number'; } ?> As seen there, my implementation of the header content-type was correct. So back to your old code: <?php $query = "SELECT content FROM image WHERE id= '1'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); header("Content-type: image/jpeg"); echo($row['content']); ?> And on a huge SIDE NOTE!!!:::::: The image must be a JPEG type that was inserted into the DB for this to work. If it was png it should be image/png or gif it should be image/gif. If you do not know what type it was I would suggest looking into storing the type when it is uploaded in the DB so you can call the correct content-type when the time is necessary.
  4. To fix the error in the code I posted: // We'll be outputting a jpeg header('Content-type: image/jpeg'); // this needs to be changed to the actual type of the image, png, gif, jpeg etc echo $row['content']; I just had the content-type wrong, should be image/jpeg.
  5. edit: removed. doing more research... http://www.google.com/search?hl=en&q=php+display+image+mysql&btnG=Google+Search&aq=f&oq=php+display+image+mysq http://www.phpriot.com/articles/images-in-mysql Will help you out.
  6. No, you do not want to the location. The header tag has many more uses. Look at the header site for other examples of "Content-type:" <?php if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert1= "SELECT * FROM users WHERE id = '$id'"; $idnu = mysql_query($insert1) or die(mysql_error()); while ($idn = mysql_fetch_assoc($idnu)) { $idnumb= "{$idn['id']}"; } } $query = "SELECT content FROM image WHERE id= '1'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); // We'll be outputting a jpeg header('Content-type: application/jpeg'); // this needs to be changed to the actual type of the image, png, gif, jpeg etc echo $row['content']; ?> I do not know if that will work but that is the basic idea. Read through the WHOLE page of header and you will see plenty of examples, especially in the user remarks. Remember the first example on PHP.NET is not always the right one or the example you need, so read through the WHOLE page.
  7. You have to set the page headers. header
  8. Not sure if this helps, but if you want a template system, Smarty Template uses Caching. As far as learning about caching not sure really.
  9. ...change the parenthesis around. if (isset($selected_section_content) && (is_numeric($selected_section_content) OR $allow)) {}
  10. if ((isset($selected_section_content) && is_numeric($selected_section_content)) OR $allow) {}
  11. Line 181 is where I make the comparisation (if($starthour < $hour < $endhour)). So < is an unexpected character in my code? I know that $hour has the right format because I echo'd it and ik came out like in the database e.g. 21:28:41 Should I compare Time's otherwise? Don't hijack threads. Create your own.
  12. count(*) is bad practice and inefficient. Use the unique identifier for the table (Primary Key) for that... $query = "SELECT COUNT(id) as num FROM thelist WHERE username = '$username' ORDER BY notices"; Should be more efficient, but not sure if this will help your problem, but yea.
  13. I was just trying to help It's ok to try to help as long as it is related to the topic. That code is not really related to the topic, it has nothing to do with MySQL and protecting the site from being SQL Injected. Sorry to be rude, but yea relevance to a topic is always a good rule to follow.
  14. $text = 'Welcome to ' . test . ',enjoy your stay'; A note, it is good practice to put constants in caps so people know that it is a constant.
  15. Why not use either index.php or index.cgi to forward to the other...whats what I would do. To get them both to work is not very probable. You have to pick one and then make the other do a 301 redirect to the one you want. The redirect can be done in the .htaccess or on the php/cgi side.
  16. imo I would start with easier stuff to learn PHP. Online games take alot of work to do and it can demotivate you quick. I would start with a user registration/login system. Once you get that down then start by adding a profile page for users. You will want to use sessions and MySQL so learn about that then from there just start building the game little by little. Like start out like the user is on level one, etc. I would also write out your storyline that you would like to go off of so you have sort of a design/outline to go by.
  17. <?php $data = shell_exec('uptime'); $uptime = explode(' up ', $data); $uptime = explode(',', $uptime[1]); $uptime = $uptime[0].', '.$uptime[1]; echo 'Uptime: '.$uptime; ?> Not sure if this works on windows, but yea. To get the last reset time you just take the uptime convert it to seconds and subtract it from the current timestamp.
  18. Show the code, the actual site will not help us solve your problem.
  19. Parse error: if ($locked == "no"); { To if ($locked == "no") {
  20. Be more descriptive of what you want...how do you get the data from the other server? cUrl? file_get_contents? Or have you thought of that?
  21. Ummm what do you mean "highlighting to green" ? What type of text editor are you using? And to answer the question, no, there is no way around it.
  22. Search Engine Optimization... Basically using ? or & or = inside of URLs ranks lower than ones that do not, simply because search engines do not like to see them Also the id is numerical, also a downside cause 99% of searches contain words not numbers. Doing it with an actual username will yield higher results especially without the ? or & and = inside the query =)
  23. That and he probably wants it to be SEO Friendly. The ? is not very SEO friendly =)
  24. Simple, I am not sure how to do it with one query, but easily done with two: <?php $numComments = mysql_query("SELECT COUNT(comment_id) as comCount, post_id FROM comments GROUP BY post_id") or die(mysql_error()); while ($row = mysql_fetch_assoc($numComments)) { $arQuery = mysql_query("SELECT * FROM articles WHERE post_id = " . $row['post_id']); $articles[$row['post_id']] = mysql_fetch_assoc($arQuery); $articles[$row['post_id']]['count'] = $row['comCount']; } print_r($articles); Then you can just use that array $articles to call what you want. This my also work, but not sure: <?php $numComments = mysql_query("SELECT COUNT(comment_id) as comCount, parent.* FROM comments, parents WHERE comments.post_id = parents.post_id GROUP BY post_id") or die(mysql_error()); while ($row = mysql_fetch_assoc($numComments)) { $rows[] = $row; } print_r($rows); If the latter one works. I would use that cause then you can place order by's etc on it.
  25. It really has nothing to do with why your script is not working, but here is how to fix those 2 issues: <?php //print_r($_POST); $error = ""; // set error to avoid notice's. if(isset($_POST['action'] && $_POST["action"] == "Upload Image") { unset($imagename); if(!isset($_FILES) && isset($HTTP_POST_FILES)) $_FILES = $HTTP_POST_FILES; if(!isset($_FILES['image_file'])) $error["image_file"] = "An image was not found."; $imagename = basename($_FILES['image_file']['name']); //echo $imagename; if(empty($imagename)) $error["imagename"] = "The name of the image was not found."; if(empty($error)) { $newimage = "file:///C|/wamp/www/images/" . $imagename; //echo $newimage; $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(empty($result)) $error["result"] = "There was an error moving the uploaded file."; } } ?> <form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?php $_SERVER["PHP_SELF"];?>"> <p><input type="file" name="image_file" size="20"></p> <p><input type="submit" value="Upload Image" name="action"></p> </form> <?php if(is_array($error)) { while(list($key, $val) = each($error)) { echo $val; echo "<br>\n"; } } ?> I will look at it closer to see why it does not work. It would be a ton easier and you might get more responses if you indented your code properly.
×
×
  • 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.