812 Posted Topics
Re: Your script seems to be OK. Check your configuration (php.ini -> [mail function] section) which depends on your environment. In my Windows XAMP on localhost all mail is written to the C:\xampp\mailoutput directory (not really sent out). | |
Re: > I wonder why after I press the button, nothing happens! Normally, if I press the button - the form suppose to be processed by carrying me to login.php <input type="button" name="submit"> The `type` should be `submit` not `button` unless you use some javascript code to submit the form. Also … | |
Re: Where does it stop? What is the error? The query: $sql = "SELECT mobno1,mobno2 FROM custreg"; presumably returns a set of rows, but $data = $q->fetch(PDO::FETCH_ASSOC); returns only one row. Is that what you aimed for? Note, you have a line of code saying: $message = urlencode($tempmsg); But where is … | |
Re: What is the server OS? If it is one of the Linux distros the path for html documents would not be the same as in Windows. A couple of examples: /var/www/html /var/www /srv So you might want to reference the web path which is not suppose to change and hardcode … | |
Re: // execute the code below only if there is a patron_ID saved in the session variable // this is probably a check if the user is logged in if(isset($_SESSION['patron_ID'])) { // this function sets max execution time of the script // in your case (0) it sets no time limit … | |
Re: It is a lot of code here :-). Basically what you have to do is you have to read the data that is already in the database and check for it within the code to see which checkboxes you have to set. From the number of queries in the script … | |
Re: It is called [AJAX](https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started). Once the page is loaded it enables you to get some more data and display it in a chosen element in the page (a div for example). It uses an XMLHTTP or XHR Javascript object that all modern browsers support to make additional request. It is … | |
Re: This bit of code seems to be OK. Are you sure that this is the line that is causing the error? Sometimes an error can occur a number of lines before. Maybe you post more code. | |
Re: > when i submit all the prices are added up , but it should only add the checked ones This is because `select sum(price) as totalamount from food` selects from all the rows you have in the table. To get only the checked items you have to read them from … | |
Re: What is the code in the welc.php? Is $uname['username'] a username (usually just one word) or users real name (like first and last name)? | |
Re: > I have tried the while loop but still I am unsuccessfull Can you specify in what way you were unsuccessful, eg. what was expected outcome and what really came out? A few comments on your code: - You should enclose your form elements within `<form>` tags and set appropriate … | |
Re: Maybe line 23: `while($row=$result->fetch_assco()){...` It should probably be: while($row=$result->fetch_assoc()){... *assoc* stands for associative; this method returns a row in an associative array where field names are keys. | |
Re: Try using result->num_rows instead (it returns number of rows found): if($result->num_rows == 0){ echo "invalid username" ; } else { echo "welcome"; } | |
Re: Use one of the PDF libraries out there. I use [tcpdf](http://www.tcpdf.org/) and am very happy with it. Find a function in your pdf library that deals with images. In tcpdf it is the `Image()` function (see an example [here](http://www.tcpdf.org/examples/example_009.phps)). You can either save the generated image to disk and use … | |
Re: Just a few thoughts: - you should check if all the required values exist before using them in the query (otherwise the query might break) - you should sanitize the values before using them in the query (otherwise you could pass some nasty user supplied data to your DB server … | |
| |
Re: 1. You are using double quoted strings so you can simplify things. Instead of: $sqlstr = "UPDATE `invoice` SET group_date='".$group_date."', group_id='".$_GET['group_id']."', group_package='".$group_package."', group_level='".$group_level."', group_teacher='".$group_teacher."' WHERE group_id='".$_GET['group_id']."'"; you can write it: $sqlstr = "UPDATE `invoice` SET group_date='$group_date', group_id='{$_GET['group_id']}', group_package='$group_package', group_level='$group_level', group_teacher='$group_teacher' WHERE group_id='{$_GET['group_id']}'"; The query is far more transparent now and … | |
Re: It is a lot of code but as it seems the `$image[photos]` is an array of photos that you should iterate through, something like: foreach($cleaned_response as $image){ foreach($image[photos] as $oneImage) { echo'<img height="100" width="100" src="'.$oneImage['fullsize'].'"/>' } } | |
Re: If you want to sort using php then you have to: 1. convert javascript array (of arrays) into php array using [json_decode](http://php.net/manual/en/function.json-decode.php) function 2. sort the php array using [array_multisort](http://php.net/manual/en/function.array-multisort.php) function This is the code, see also comments in the code: // this is original string representing a javascript array … | |
Re: Something like this might help: $oldArray = array( 'item-_token' => 'k4i2tQbZNuKnhV0vqbdBJ0XlwKzGLm09KA0pWa5n', 'item-link' => array ('link 1', 'link 2', 'link 3'), 'item-shop_name' => array('a', 'b', 'c'), 'item-color' => array('blue', 'yellow', 'black') // ... ); $newArray = array(); foreach($oldArray as $key1 => $arr1) { // do not know what to do with … | |
Re: Make a file that will contain all your functions, something like functions.php. You can put it in a special folder if you wish (like lib or something). The include this file whenever you need to call any of contained functions. You use either [include](http://php.net/manual/en/function.include.php) or [require](http://php.net/manual/en/function.require.php) construct for that. The … | |
Re: Your script might work if you change line 2 to: if(isset($_POST['Submit'])) since you usualy check whether the form was submited (but this is more or less just a guess). However, do take seriously above notes about security. | |
Re: It would be helpful if we see the actual data in the array. Put this code between lines 10 and 11: die(print_r($skills_1, 1)); Post the output here. It is also (usually) easier to use a foreach loop to process an array instead of all the for stuff. | |
Re: If no event has been selected from the dropdown, you are in trouble since $_POST['events'] possibly does not exist and you get a notice (the script obviously gets executed anyway). What you have to do is to check for existence and act appropriately: if(isset($_POST['events'])) { $event = $_POST['events']; } else … | |
Re: // initialize output array $outputArray = array(); $tmpArray = explode("/", $aName); foreach ($tmpArray as $tmpString) { $tmpOneRow = explode("-", $tmpString); // add two elements to the output array $outputArray[] = $tmpOneRow[0]; $outputArray[] = $tmpOneRow[1]; } // check the result print_r($outputArray); Beware: no error checking in above example. You might want … | |
Re: Se the [manual](http://www.php.net/manual/en/mysqli.query.php) - the *procedural style* part. The mysqli_query expects two parameters, the link and the query. Similar goes for the [mysqli_error](http://si1.php.net/manual/en/mysqli.error.php). It expects the link in procedural version. | |
Re: The option that should be selected has to have a `selected="selected"` attribute. To find out which one it is, you do a check in each iterration. Suppose that com_FirstName is the criteria as in your example: // committee member that has taken the book in $comiteMemeber = 'John'; while($row_com = … | |
Re: Maybe you should read this: http://www.php.net/manual/en/book.gettext.php ![]() | |
Re: It works perfectly well in my browser (Firefox 30 on Win7). Clicking on a *View page source* it shows 5 tabs. | |
Re: Your query is designed to read the data only for one customer with the current $CustomerID. You have to change the query to read all (or selected set of) customers. But how would you display the invoices then (say for a few hundred of customers)?? | |
Re: Why don't you do it simple way: // first check if it is or isn't a number if(!is_numeric($points)) { echo "Points can't be text"; // then try all possible values } elseif($points == 0) { echo "Clean 0"; } elseif($points > 0 && $points <= 50) { echo "You did … | |
Re: On line 6 you must enclose the associative index in quotes. Consequently you have to change the code for the query slightly, like: mysql_query("SELECT LRCard FROM student_information where student_id='" . $_GET['id'] . "'"); or: mysql_query("SELECT LRCard FROM student_information where student_id='{$_GET['id']}'"); | |
Re: It would help if you could be more specific. Show some code so we can see things like the array structure and values, the table structure, the complete error message etc. | |
Re: I hope I understood OK what you want. I suggest you do it as a single unordered list and use css styling (classes) to handle indent. I am posting an example with code for complete page so you can see what I mean. You can adapt CSS to suit your … | |
Re: If you wish to use the above soultion by ehpratah you will have to use ajax since queries can not be performed by javascript itself. You can use a [jquery Ajax method](http://api.jquery.com/jquery.ajax/). | |
![]() | Re: Nice job. Haven't tested the class but after scanning the code it is obvious that this is a nice example of clean coding / useful functionality. Quite some work must have been put into this to gather all the information an put it into this little tool. I remember myself … ![]() |
Re: Shouldn't line 2 be: $query = "SELECT * FROM users"; (without the mysql_query part)? ![]() | |
Re: Maybe storing session data in database would give you control you need. See this article about the topic: http://shiflett.org/articles/storing-sessions-in-a-database | |
Re: Post the bit of code that uses the `mysql_real_escape_string()` function. It is important that you give this function a string as a parameter (not an array as in your case). ![]() | |
Re: You will have to check for values of each of the fields and build the query accordingly. Something like: $query = "SELECT Schedule.Channel_Number, StationInformation.Station_Name, Schedule.Program_Name, Schedule.Date, Schedule.Time FROM Schedule INNER JOIN StationInformation ON Schedule.Channel_Number=StationInformation.Channel_Number INNER JOIN TVShows ON Schedule.Program_Name=TVShows.Program_Name WHERE 1 "; If(isset($_POST['date']) && !empty($_POST['date'])) { $date = mysql_real_escape_string($_POST['date']); $query … | |
Re: Seems like **eburlea** was right in his first post since there is no `$query` variable in your script. Try looping over the query object directly: foreach ($db->query($sql) as $row) { $product = $row['product']; $price = $row['price']; echo "<tr>"; echo "<td>" .$product ."</td>"; echo "<td>" .$price ."</td>"; echo "</tr>"; } I … | |
Re: Here's another Excel library with good documentation and examples: https://phpexcel.codeplex.com/ | |
Re: Why don't you use the second parameter of the `load()` function for sending it over to the theServiceOrderReport.php. You basically do not need a session var for that. First add an ID to the select element: <select name="ServiceOrders" id="ServiceOrders"> Then read its value and send it over with the load(): … | |
Re: In your code you use both mssql_* and mysql_* functions. Do you use two different database servers or is that just a typo from copying from some examples? | |
| |
Re: Seems like $role is an array and therefore won't display as a string. Can you post the contents of the $role - you do this by using print_r($role). Edit: I forgot to mention I am not a WP expert. | |
Re: Select element names are `venueID` and `catID` but the field names in the array are `te_events.venueID` and `te_events.catID` so you do not get a match here (`isset($_POST[$field])` returns `false`). | |
Re: To add to the above reply: PDF Extension uses PDFlib library which is not free (you have to purchase it). TCPDF and FPDF are free. TCPDF is better maintained and actively developed, while FPDF is being more or less idle (last version from June 2011). They both do their job … | |
Re: Nice little function for sending mail if you do not want to be bothered with the details about coding the neccesary mail commands. I haven't tested it but it looks clean and tidy. | |
Re: Adapted from the [PHP site example](http://si1.php.net/readdir): // path to the directory with files (relative to the script) $path = '.'; // URL to the above path from the browser $url = 'http://www.example.com/download/'; if ($handle = opendir($path)) { // loop through directory entries while (false !== ($entry = readdir($handle))) { // … ![]() |
The End.