812 Posted Topics
Re: Use explode and implode and form an SQL statement: $values = explode(' ', "claim for my new mercedes"); $sql = "INSERT INTO mytable VALUES ('" . implode("','", "$values") . "')"; Or use str_replace and form an SQL statement: $sql = "INSERT INTO mytable VALUES ('" . str_replace(' ', "','", "claim … | |
Re: I am not sure whether writing banned IP addresses in htaccess file is a good idea. You will need approprite rights to write into it and the file will grow with users visiting your site which might affect performance. Also maintaing the list (i.e removing duplicate entries) in the htaccess … ![]() | |
Re: Typically you would load all three divs with images of different size. One of the divs will be displayed while the other two will not. You use `display:block` for displayed div and `display:none` property for the two other divs: <div id="large" style="display:none"><img... <div id="medium" style="display:block"><img... <div id="small" style="display:block"><img... or appropriate … | |
Re: [phpacademy](https://phpacademy.org/) - learning by watching videos, various PHP forums like [Daniweb](http://www.daniweb.com) :-), [Stackoverflow](http://stackoverflow.com/questions/tagged/php), a good [book](http://www.amazon.com/Beginning-PHP5-Apache-MySQL-Development/dp/0764579665) on PHP, the [documentation](http://www.php.net/manual/en/) on the PHP.net site (comprehensive, free, but sometimes harder to get through it) and a lot of experimenting - set up LAMP or XAMP and go for it. And do … | |
Re: Are you starting session anywhere? If you have session_start then session variables should be available to you. | |
Re: Could you be more specific. Would you like to find all the checkboxes that are clicked? That is easy to implement with the [checked selector](http://api.jquery.com/checked-selector/). | |
Re: Describe your tables in a way that you can create forms and generate queries. A simple way of doing it would be to have table fields stored in an associative array where keys would be field names and values would be field types. That way you can tell whether to … | |
Re: This is what uncle Google told me: http://www.php.net/manual/en/function.id3-get-tag.php ![]() | |
Re: I use TCPDF library (http://www.tcpdf.org/). It is being actively developed, has examples, it works and it is free. | |
Re: > After I download it offline to run it in my localhost, that error start appearing. What do you mean by that? You can not download PHP code from a web page, can you? Anyway, the error you are getting means that you are sending some HTML output before the … | |
Re: I would use [jquery](http://jquery.com/) and either [hover](http://api.jquery.com/hover/) or [on](http://api.jquery.com/on/) method. The later is preferred since it gives more controls over event handling. | |
Re: Where is the information about the logged-in user stored? Let's assume that is stored in the session in the `$_SESSION['loggedin_username']` variable. Now while fetching rows you have to check whether the fetched username equals to the logged-in username. So the code would be something like: <?php include('includes/setting.php'); $for=mysql_query('SELECT * FROM … | |
Re: In general you: 1. check for existence of any input (in $_GET or $_POST) 2. clean existing input 3. display it in the corresponding form fields For detailed answer you should post your existing code. | |
Re: Newline in HTML is `<br>` tag (a break): echo $row_selecttemptable['ArtistName'] . ' ,<br>' . $row_selecttemptable['NAMEOfTheDVD'];` ![]() | |
Re: > i want to know about php.net language? [php.net](http://php.net/) is actually a website (that incidentally tells you all about PHP). Seems like you are new to this forum. Welcome and hope you will find it useful. And since your question is pretty general I suggest you read [this article](http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question) first … | |
Re: For one thing you are missing quotes arround associative index names. Since the array elements are complex variables you should also enclose them in curly braces to get them parsed properly in a double quoted string. Another issue is that you echo the if condition which is not right. Then … | |
![]() | Re: The code on line 9 is wrong, it wont return what you expect. You could change your query a bit and ad `AS` to the substring expression in the query: SELECT runners.raceid, SUBSTRING(runners.raceid,1,4) AS raceyear,... and then change line 9 in the code to: echo $row['raceyear']; ![]() |
Re: Use javascript and on change event on the quantitiy input field that would triger a function. Something like (not tested): <input name="quantity" type="number" min="1" max="20" value="1" id="quantityfield" onchange="updateQuantity();"> ... <script type="text/javascript"> function updateQuantity() { var quantity = document.getElementById("quantityfield").value; var price = <?php echo $row_itemdetaille['price']; ?>; document.getElementById("totalfield").value = quantity * price; … | |
Re: To get the same hash use the same string for 30 days. There are many ways to accomplish this. One of them could be: Initially: - store the initial string for hashing in the users record in database - set the cookie that expires in 30 days Everytime you need … | |
Re: Your condition is wrong since it checks if either submit is set (which always is after submitting) or $service_name has some text. The condition is always true and the values are inserted (if they do not exist). The correct condition would be using && (and): if($submit=='submit' && strlen($service_name) > 0 … | |
Re: It works? The results might be unpredictable. In line 9 the id in $_SESSION['id'] is not existing. So better check for existence before using it: if(isset($_SESSION['id'])) { switch($_SESSION['id']) { ... } | |
Re: Have an array with indexes the values and elements the words you want to represent the values: $numbers_array = array('1' => 'one', '2' => 'two', '3' => 'three'); // wrap everything within form tags echo '<form action="#" method="post">'; // use PHP to construct the select element echo '<select name="numbers">'; foreach($numbers_array … | |
Re: There might be some errors in your script(s), but your web server is not telling you about them since most probably the display of errors is turned off. Change the following settings in your php.ini: error_reporting=E_ALL display_errors=On and restart your web server. The errors could be in the included inc/config.php … | |
Re: On line 5 you are trying to write date object into the text file. It won't go. Also the third argument to the fwrite is optional string leght. I doubt you wanted to use it that way. Change line 5 to something like: fwrite($file, $ip . ' ' . $dt->format('Y-m-d … | |
Re: Decide on how many characters you can display. Then change line 30 from: <td ><?php echo $row['service_content']; ?></td> to: <td > <?php $contentLength = strlen($row['service_content']); // check if the length of the content exceeds max number of chars e.g. 120 if($contentLength > 120) { echo substr($row['service_content'], 0, 120) . '...'; … | |
Re: Check what the $array content is. Is it an array of objetcs (this is how you reffer to each row)? To check the contents of the array insert this temporary debug code after line 5 in the second code snippet: die(print_r($array, 1)); This will display the contents of the $array … | |
Re: You have a space in the src URL, just before the $photo variable: echo " ".$results['image']."<a href='http://www.mysite.org/br/s.php?id=$id'><img src='/cate/upload/ $photo' width='100%' height='100%'></a>" | |
Re: Here is and example of a script that resets the password and mails new password to the user. http://www.daveismyname.com/tutorials/php-tutorials/reset-password-script/ I prefer slightly different approach. When user forgets his password he is sent a temporary link to a form where he can create new password. You can find examples by googling … ![]() | |
Re: If you want to learn more about this google for cyclomatic complexity. See [this article](http://en.wikipedia.org/wiki/Cyclomatic_complexity) on Wikipedia. ![]() | |
Re: Not exactly a PHP related question but anyway: do you have the ending `</a>` tag? Is your other HTML code OK? | |
Re: // set the array with month names $monthNames = array('January', 'February', ...); // this is your date in a form of a string $dateString = '2013-12-25'; // change it to an array $dateArray = explode('-', $dateString); // month is the second element (-1 to get the correct index) $Month = … | |
Re: You should not echo any output before the header command. Remove line 56: echo "<p class='red-info'> Record Saved! </p>"; so the headers can be sent. This command is pointless anyway since the page would get redirected. | |
Re: A bit more code would help. Where do you echo it? Maybe it gets changed somewhere in the process? contest[name] the index should be enclosed in quotes: contest['name'] and enclosed in curly braces if used in a double quoted string: ...id="contest-name" name="{contest['name']}" value="' ... | |
Re: What was the problem with the layout? TCPDF is quite flexible and I did not have problems creating nice tables. | |
Re: To recap the above two posts: // check whether $_GET has any value and if the value is valid // (you might use some more proper validation depending on the value of the movie ID) if(isset($_GET['movie_id']) && !empty($_GET['movie_id'])) { $query = "SELECT movie_name,movie_year,movie_director,movie_leadactor,movie_type,movie_running_time,movie_cost,movie_takings FROM movie WHERE movie_id= " . mysql_real_escape_string($_GET['movie_id']); … | |
Re: Maybe the simplest way would be to address the array element directly: $eng['profile_permission'] = 'You belong to ' . $group . ' with a permission of ' . $permission .''; or using double quotes: $eng['profile_permission'] = "You belong to $group with a permission of $permission"; | |
Just to alert admins that some spamming is just happenning in the PHP forum here on Daniweb. Please take a look. | |
Re: > i don't understand. how does this solve my problem? If number of [affected rows](http://www.php.net/manual/en/function.mysql-affected-rows.php) equals 0 no rows were deleted. That might be the case if no rows matched $idURL. But to check there are no other issues, use simple debugging technique - insert this code right after line … ![]() | |
Re: If the array that is sent as a parameter to the $liquid->render() method has to have same form as teh $assigns array then you have to read the data from the database and put it into an array of the above mentioned form. The details depend on the table structures … | |
Re: Simply change the action attribute to the same page like: <form method="post" action="#"> or: <form method="post" action="<?php echo __FILE__; ?>"> | |
Re: Show us the rest of the code. From this snippet it is impossible to tell what is wrong. Could be html tags mismatch. | |
Re: Are you viewing this locally? Do you have a web server with php running? Is your script a PHP file? In other words: PHP scripts should have a .php exstension (not .html) and should be run on a PHP enabled web server (could be localhost or a server embeded into … | |
Re: Videos: https://phpacademy.org/. And of course [php.net](http://www.php.net/manual/en/). It might take some time to get used to it but at the end of the day it is a wealth of information. Everything is there. ![]() | |
Re: Something like: <?php // set styles the way you want if($time < 8) { $tdStyle='background-color:green;'; } else { $tdStyle='background-color:red;'; } while($row=mysql_fetch_array($result)) { echo "</td><td style=\"$tdStyle\">"; echo $row['full_name']; echo "</td><td style=\"$tdStyle\">"; echo $row['section']; echo "</td><td style=\"$tdStyle\">"; echo $row['time']; echo "</td><td style=\"$tdStyle\">"; echo $row['reason']; echo "</td></tr>"; } echo "</table>"; ?> Please note … | |
Re: Check out if the `$insertGoTo` variable has same value in both cases. Put this temporary line of code just before line 16: die($insertGoTo); Now see if the same value is displayed on the localhost and the web hosting server. And also: you can simplify the header function like this: header("Location: … | |
Re: You can do it all in Javascript if you do not need server processing. In this case just write a function to convert number to words and fire it on keyup event. Now, if you need to process numbers on a server (as it seems from your post) then you … | |
Re: As far as I can see $res2 does not depend on $query2. Can you put this temporary debug code just after line 38 and post the result here: die($row2['country_name'] . ' ' . $res2); | |
Re: Maybe this link can help a bit: http://stackoverflow.com/questions/3740845/php-session-without-cookies But keep in mind there are security issues with this. | |
Re: Something like (not tested): // check if the number of fields is multiple of 4 if(count($array) % 4 == 0) { // start building the query $query = 'INSERT INTO yourdatabase (`field1`, `field2`, `field3`, `field4`) VALUES '; // add values to the query for($x = 0; $x < $count($array); $x … | |
Re: Use [HTML5 video](http://www.html5rocks.com/en/tutorials/video/basics/) tag. |
The End.