-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
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
-
@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"
-
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?
-
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>';
-
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.
-
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.
-
What is your current code?
-
Will not echo the new user welcome paragraph
Ch0cu3r replied to Shadow_Walker's topic in PHP Coding Help
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!'; } -
That is json. PHP has a built-in function for converting an array to JSON for you called json_encode
-
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
-
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.
-
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();
-
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 }
-
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.
-
Can you post your current code? And specify exactly what you are stuck on.
-
What does it mean by table? Is it a (My)SQL Database table returned by your query? NB: I have corrected your topic title
-
What you need to learn is HTML. The HTML anchor tag is what creates links <a href="aboutus.php">About Us</a>
-
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?
-
How are you getting error 404?
-
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.
-
If you comment the header() line are any errors shown?
-
Remove the single quotes. They are not needed
-
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
-
Uploading images inside Dreamweaver
Ch0cu3r replied to Adam_Duski's topic in Editor Help (PhpStorm, VS Code, etc)
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.- 4 replies
-
- dreamweaver
- upload
-
(and 1 more)
Tagged with:
-
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; }