Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Because the PDO::Query method returns the PDO Statement Object. I think you're confused here. The fetch() method is not a static method, it is a public method that belongs to the PDO Statement Object. PDO::FETCH_OBJ on the other-hand is a static constant which returns the value of the FETCH_OBJ constant from the PDO class. This constant tells the fetch() method how you want the records in the record set represented as. In your case it'll be in a standard object form. Other types could be an associative array (PDO:FETCH_ARRAY), or as a numerically index array (PDO::FETCH_ROW).
  2. The error is self explanatory the variable $row_katefori_cek is not defined. Make sure you have spelt the variable name correctly. If you are still unsure, then you need to post more code.
  3. Added comments to show_image.php <?php // connect to database mysql_connect("localhost","",""); mysql_select_db("moduni_images"); // grab the id query string paramter if(isset($_GET['id']) && ctype_digit($_GET['id'])) { // sanitize the id query string param $id = intval($_GET['id']); // select the image from the images table where the image id matches $id $query = mysql_query("SELECT * FROM `images` WHERE id = $id"); // output the jpeg image content type header header("content-type: image/jpeg"); // output the image binary echo $row["image"]; // stop script execution exit; } else { echo "Error!"; }
  4. The second sentence explains it from the page I linked to.
  5. You need to retrieve the image where the image id matches $_GET['id']! <?php mysql_connect("localhost","",""); mysql_select_db("moduni_images"); if(isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $query = mysql_query("SELECT * FROM `images` WHERE id = " . intval($_GET['id'])); header("content-type: image/jpeg"); echo $row["image"]; exit; } else { echo "Error!"; }
  6. You should be looking at the manual on PDO prepared statements for the answer. The manual is always the first place you should look for understanding what a function does.
  7. To get the error message with PDO, either run your prepare query in a try/catch block to catch the exception Or use PDO::errorInfo Also dont use die to output errors. It is ok for development but not when your code goes live. Instead use trigger_error
  8. So you want to display the 4 most recent images uploaded? You'd use a SELECT query, ordering the results by id in descending order and then apply LIMIT of 4, example query SELECT * FROM images ORDER BY id DESC LIMIT 4 Applying the query to the code <div id="user-gallery"> <h2>Gallery</h2> <?php $result = mysql_query('SELECT id FROM images ORDER BY id DESC LIMIT 4'); // grab the 4 most recent images from database while($row = mysql_fetch_assoc($result)) { ?> <div class="img"> <a href="scripts/show_image.php?id=<?php echo $row['id'] ?>" data-lightbox="image-1"> <img src="scripts/show_image.php?id=<?php echo $row['id] ?>" width="125px" height="71px"> </a> </div> <?php } ?> </div>
  9. Use the MySQL NOW() function explicitly in your query.
  10. Explain what you by that? Are you referring to installing MAMP or Symfony?
  11. Not a mac user, But if you have MAMP installed and have gone through the installation steps here then Apache, PHP and MySQL should be set up and ready to go. To install symfony, just download it and extract the archive to your web directory (default path is /Applications/MAMP/htdocs - according to the docs liked above).
  12. You'd use PDOStmt::rowCount
  13. If I understand correctly, all you need to is concatenate the two values <ad-content type=\"rtf\">".htmlentities(base64_encode('\fs13'.$ad->photo_file_name.$ad->text))."</ad-content>";
  14. The code suggested by mac_gvar should work for you. If not post your header file here ( either the paste code between code tags or attach it).
  15. You get the value of the cookie, using mac_gver's second code snippet!
  16. The values of cookies are not updated until the next page request/reload. This is because cookies are sent to and from the client during HTTP requests. After step 3 if you reload the page, the $_COOKIE['defaultLanguage'] should reflect the new value of the chosen language made by the user. An alternative to cookies is (server-side) sessions. Any changes made to sessions will be immediate, only difference is the session data is stored server side rather than client side.
  17. Then replace $newpost in your code with file_get_contents
  18. Ok looking further at your code. Here public function get_status(&$ServerIP,&$ServerPort){ You have defined the ServerIP and ServerPort arguments can only be passed by reference (this is what the & means before the variable name). Because of this you cannot pass a hardcoded value (such as string or integer) when calling the method. You can however call it like this $ip = "0.0.0.0"; $port = 80; /* on calling this method $ip and $port will be passed by reference */ echo "STATUS: ".$servers->get_status($ip , $port); Next remove $this. from in front of the variables on this line (why are you concatenating the object here?). And remove the error suppression operator ( @ ) too. if(@stream_socket_client("tcp://".$this.$ServerIP.":".$this.$ServerPort."", $errno, $errstr, 1) !== false) {
  19. First try moving your error reporting code to index.php Also paths beginning with a / mean it will load the file from the root of the hard drive, not the sites root (were you domain points to).
  20. Yep its called composer A quick google search, CakePHP can be installed using composer and so too can Wordpress
  21. Because you are using single quotes for denoting the textarea id. Change your single quotes to double quotes instead $string = ""; $string .= "<textarea id=\"convert\"> 'AA' </textarea>"; $string .= "<textarea id=\"convert\"> 'BB' </textarea>"; $string .= "<textarea id=\"not_convert\"> 'CC' </textarea>"; $string .= "<textarea id=\"not_convert\"> 'DD' </textarea>";
  22. After you have defined the $string variable.
  23. Could try this if your using PHP 5.3.0 or newer $string = preg_replace_callback('/(<textarea id="convert">)(.*?)(<\/textarea>)/is' ,function($m) { array_shift($m); $m[1] = str_replace('AA', 'ZZ', $m[1]); return implode($m); } ,$string); echo $string;
  24. Just install PHP on all laptop and run your app of off PHP's internal server.
  25. You can run phpinfo in a php script. If you find a SimpleXML heading then it is enabled.
×
×
  • 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.