Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Ugh Dreamweaver code The problem is here $insertSQL = sprintf("INSERT INTO kommentar (tittel, navn, tekst, tidsstempel, innleggid) VALUES ( %s, %s, %s, NOW(), %s)' // ^--- Should be a " double quote The single quote at the end of that line needs to be a double quote
  2. @HeyAwesomePeople your code is fine, the problem is you seem to be wrapping your HTML attributes in two or three sets of double quotes eg attr=""value"" . Attribute values should only be wrapped in one set of double quotes eg attr="value"
  3. You are getting that error because you do not have a clients table in your users database. So have you checked to make sure you have setup the database correctly on your home computer?
  4. You cannot echo an array. Maybe use $names = $mysql->display_sql_list($bookpage_table_name); echo implode(',', $names); // OR, echo names into a HTML list echo '<ul><li>' . implode('</li><li>', $names) . '</li></ul>';
  5. Have a read on the man page for imagettftext() this function is what writes the text to your image. You position the the text using the 4th and 5th arguments, these handle the xy position of the text.
  6. The code for the function is fine, it returns an array of names. The error is produced line 5 of booking_list.php. What are you doing on that line? Post the first 5 lines of code from that file.
  7. What is your current code?
  8. First these action="Student_Home.php" method="post" Should not be used in an <input /> they are attributes to control the behaviour of a <form>. Example code of a form with 1 input and submit button <form action="Student_Home.php" method="post"> Student ID: <input type="text" name="student_id" /> <input type="submit" value="Submit" /> </form> Secondly you're getting the notice message because $_POST['student_id'] wont exist, until the form has been submitted so you need to check that it exists before using it, example // check whether $_POST['student_id'] exists // form has been submitted if(isset($_POST['student_id'])) { echo 'Welcome, ' . $_POST['student_id']; } // $_POST['student_id'] does not exist, display a message else { echo 'Please provide Student ID!'; }
  9. That is json. PHP has a built-in function for converting an array to JSON for you called json_encode
  10. MaxRequestLen is currently capped to 128KB. Your file upload is exceeding this cap which is causing the 500 Internal Server Error. If you have access to the servers config, then you need to increase the current cap set for MaxRequestLen so it is greater than 131072 bytes (128KB) to allow for your file uploads
  11. Your http server is encountering an error, this is why you are getting Internal Server Error 500 message. You need to look at your servers error log to find out the cause of this error.
  12. You need to echo mysql_error to see what the error is. Post the full error message here and we'll try to help solve it for you. $results = mysql_query($result = "SELECT * FROM clients WHERE name like '%".$keywoord. "%' \n" . "OR\n" . " address like '%". $keywoord. "%' \n" . "OR\n" . " contact like '%". $keywoord. "%' ;"); // output mysql error if(!$results) echo 'DB Error: ' . mysql_error();
  13. You'd use $row['posted'] instead of $post['created'] on this line of code of the code in your OP $createdday= strtotime($post['created']); //mysql timestamp of when post was created However, it'll be best to add that code you posted in your OP to a function, the just pass in $row['posted'] as an argument The function definition function facebook_date_format($timestamp) { $today = time(); $createdday= strtotime($timestamp); //mysql timestamp of when post was created $datediff = abs($today - $createdday); $difftext=""; $years = floor($datediff / (365*60*60*24)); $months = floor(($datediff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($datediff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); $hours= floor($datediff/3600); $minutes= floor($datediff/60); $seconds= floor($datediff); //year checker if($difftext=="") { if($years>1) $difftext=$years." years ago"; elseif($years==1) $difftext=$years." year ago"; } //month checker if($difftext=="") { if($months>1) $difftext=$months." months ago"; elseif($months==1) $difftext=$months." month ago"; } //month checker if($difftext=="") { if($days>1) $difftext=$days." days ago"; elseif($days==1) $difftext=$days." day ago"; } //hour checker if($difftext=="") { if($hours>1) $difftext=$hours." hours ago"; elseif($hours==1) $difftext=$hours." hour ago"; } //minutes checker if($difftext=="") { if($minutes>1) $difftext=$minutes." minutes ago"; elseif($minutes==1) $difftext=$minutes." minute ago"; } //seconds checker if($difftext=="") { if($seconds>1) $difftext=$seconds." seconds ago"; elseif($seconds==1) $difftext=$seconds." second ago"; } return $difftext; } Now your while loop will be while ($row = mysql_fetch_assoc($get)) { echo facebook_date_format($row['posted']); // pass the timestamp to the function, it'll return the date in facebook date format }
  14. No, you need to give MySQL a valid timestamp when adding a value to your (date) posted column. $insert = mysql_query("INSERT INTO posts (comment, posted) VALUES($comment, NOW())"); You'd only covert the timestamp to your facebook date format when getting it from the database.
  15. Can you post your current code? And specify exactly what you are stuck on.
  16. What does it mean by table? Is it a (My)SQL Database table returned by your query? NB: I have corrected your topic title
  17. What you need to learn is HTML. The HTML anchor tag is what creates links <a href="aboutus.php">About Us</a>
  18. So you are accessing http://localhost/ and you immediately get a 404 error? Does directly accessing a file resolve ok?, eg http://localhost/somefile.php If no, then there appears to be an issue with your (Apache) http server config. How have you configured/setup Apache?
  19. How are you getting error 404?
  20. Error 404 has nothing to with databases. You will however get that error if you are requesting for a file which the server cannot find.
  21. If you comment the header() line are any errors shown?
  22. Remove the single quotes. They are not needed
  23. No, you need to reference the class ($this). So you'd use $this->method1() The same applies to accessing properties too. Have a read of http://php.net/manual/en/language.oop5.basic.php
  24. As trg said Dreamweaver is a text editor. Although it can connect to databases it is not the correct tool to be use for for managing a database, such as adding/removing records. Instead you should be using software like MySQL workbench or phpMyAdmin which their sole purpose is directed towards managing a database.
  25. Create a function similar to your getPosition function , pass it the teamData array but only echo out the win, lost and drew items from that array function getResults($teamData){ return "Team ". $teamData["team"] ." has Won ". $teamData["won"] ." games, lost " . $teamData["lost"] . " games and drew " . $teamData['drew'] . " games"; } You'll use the following switch case statement to call the necessary function based on what user selected from form (Position or Results) switch($_POST['data']) { case 'position': echo getPosition($teamData); break; case 'results': echo getResults($teamData); break; }
×
×
  • 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.