812 Posted Topics
Re: Make the ID of a record in your students table autoincrement and use it as a primary key. If this is not an option, check for existence of the record first with `SELECT COUNT(*)`. A note on security: do not use $_GET array values directly in your insert query since … | |
Re: The pages have to be in the directory that Apache is configured to serve. In Linux this is often /var/www/html. The Apache directive that defines this directory is in httpd.conf and is called DocumentRoot. So in above example in Linux it would be `DocumentRoot "/var/www/html"`. And of course Apache server … | |
Re: // if values exist in $_POST (or $_GET if you use it) if(isset($_POST['product_id']) && isset($_POST['country_id'])) { // product ID $product_id = $_POST['product_id']; // begin the query $query = 'INSERT INTO countries_product (coutry_id, product_id) VALUES '; // add coutry ID's foreach($_POST['country_id'] as $country_id) { $query = "($country_id, $product_id),"; } // remove … | |
Hi there It's not a complaint just a note: when I hover over the adds on DW pages my Firefox often crashes (and says 'Well, this is embarassing...'). I learned to live with that (patience is my strong attribute) but thought you might want to know (also I do not … | |
Re: Hi Tomas and welcome. The answer is: Java is not neccessary. To create a website, theoreticaly, HTML is enough. In practice CSS is a must also (to make page look nice and to de-couple contents and design) as well as Javascript (to do many client side things like form validation … | |
Re: Have you tested what are the values are in the $_GET? Are they comming from a form or you construct a URL + query string some other way? You should always check for posted values: if(isset($_GET['file']) && isset($_GET['image'])) { $file = $_GET['file']; $image = $_GET['image']; } else { // handle … | |
Re: The way you use foreach looks strange to me. foreach($_POST['bot'] as $bot && $_POST['mt'] as $mt && $_POST['eot'] as $eot) { $insert = ""INSERT INTO marks(beginning_of_term,mid_term,end_of_term) VALUES($bot,$mt,$eot); $execute_insert = mysql_query($insert); } The PHP manual says: foreach (array_expression as $value) statement foreach (array_expression as $key => $value) statement `$_POST['bot'] as $bot … | |
Re: It is not evident from your code where the $price is getting echoed. This should work: $result = mysql_query("SELECT * FROM `order` where date = '$date' "); $price = $row['total_price'] + $row['total_price']; echo "Double price is $price<br />"; } as long as $row['total_price'] exists and has some value; | |
Re: If by email brodcast you mean sending mail to many recipients using php then look at swiftMailer. http://swiftmailer.org/ | |
Re: Is there any reason that you implemented the functionality in javascript? You could probably do the same processing with php and just mail the values. But if you really want to use javascript for processing then you will have to use ajax approach - a javascript function that passes values … | |
Re: Create the javascript using PHP (see the comments in the code): // suppose this is the rows array you get form the database $rows = array( array( 'sort' => 'sort1', 'url' => 'url1', 'details' => 'detail1', 'image' => 'image1' ), array( 'sort' => 'sort2', 'url' => 'url2', 'details' => 'detail2', … | |
Re: In the database each user should have a group number (or you should have some other mechanism in place to distinguish groups). Then on the **login page** you redirect a user to the page for his group using using `switch` statement and `header('location:mygroup.php')`. switch($userGroup) { case 1: header('location:group1.php'); break; case … | |
Re: `a` and `t` are format characters in the date function. If you want to use them as text (literally) you must escape each of them. | |
Re: $_FILES['photo_file'] does not exist for some reason. Good practice is to check for existance first: if(!isset($_FILES['photo_file'])) { // handle the wrror the way you see fit die('Error uploading the file'); } // code for normal processing | |
Re: To display row(s) you should add a variant of a fetch statement: $tables = mysql_fetch_row($result); echo print_r(tables, 1); http://www.php.net/manual/en/function.mysql-fetch-array.php http://www.php.net/manual/en/function.mysql-fetch-assoc.php http://www.php.net/manual/en/function.mysql-fetch-field.php http://www.php.net/manual/en/function.mysql-fetch-object.php http://www.php.net/manual/en/function.mysql-fetch-row.php Also mysqli is newer extension and is recommended to be used instead of mysql you use. http://www.php.net/manual/en/book.mysqli.php | |
Re: Each post has to be associated with the user ID (the ID of the user that authored it). I presume user ID is also stored in the session. So when you display posts you check each post to whom it belongs and if it belongs to currently logged-in user also … | |
Re: I am not familiar with FormMail but maybe this link helps: http://www.scriptarchive.com/readme/formmail.html#email In line 215 it uses PHP's internal mail function to send mail. There it sets in additional headers the From: addres using $post['email'] which some server reuire (I guess). But I think PHP's mail function sends mail using … | |
Re: Also while developing scripts it is useful to have error reporting switched on so instead of a blank screen you get some useful information. You can do this either in your script (each of them): ini_set('display_errors',1); error_reporting(E_ALL); or in the php.ini file if you have access to it: error_reporting = … | |
Re: If videos.videoname is a string you should enclose $search in quotes (line 14): WHERE videos.videoname='$search' Have you tried to debug the code by inserting echo, die or print_r debug statements like: // in line 2 to check the value sent over die($_POST['search']) // or between lines 20 and 21 to … | |
Re: This topic seems to be quite popular these days. Have a look at this thread: http://www.daniweb.com/web-development/php/threads/432815/fetch-result-in-my-drop-down-list#post1862915 | |
Re: Where do you get stuck? The principle is: construct appropriate query to retrieve rows from the table and then use data of each row to build option elements: // query $q = 'SELECT id, title FROM movies'; // connection and querrying stuff ... // start the html code for select … | |
Re: The trouble could be in your query on line 16 where you should use the variables (but you probably only forgot the $ sign). The correct query would be: $checkUsername=mysql_query("select Username, Password from registration where Username='$Username' and Password='$Password'"); | |
Re: If you want to use a php variable in html enclose it within the `<?php ?>` tags and echo it: onclick="showRemarks(' <?php echo $activityid; ?>');" id="remarksadd"></img> | |
Re: Regarding the checkboxes (or tick boxes, as you call them): when processing the posted values you have to check for an existence of a value of each checkbox. If the check box was not clicked, the value does not exist in the $_POST array. if(isset($_POST['disabilities'])) { $disabilities = 'Yes'; } … | |
Re: Possible cause might be an endless loop. Check your for and while loops wheter they end as intended. | |
Re: Echo the problematic query that the second code generates and post it. Also enclose field names within backticks since there might be a possibility that the generated field name is a mysql keyword. | |
Re: Hope this works for you: order deny,allow deny from all allow from [your IP] http://httpd.apache.org/docs/2.2/howto/access.html | |
Re: Please post the code of the page that causes above problem. | |
Re: Maybe not a direct answer to your question but you could use a `mysqli_fetch_object` function which stores result in an object instead of in an array. In PHP (v 5.something I guess) object are by default passed by reference so you do not have to wory about that. Has somebody … | |
Re: First row has first five columns with rowspan=2 and last column with colspan=4. Second row has only the last four cells. <tr> <td rowspan="2">col 1</td> <td rowspan="2">col 2</td> <td rowspan="2">col 3</td> <td rowspan="2">col 4</td> <td rowspan="2">col 5</td> <td colspan="4">Qualification</td> </tr> <tr> <td>Ed</td> <td>Tr</td> <td>Ex</td> <td>El</td> </tr> | |
Re: Here is my suggestion that uses some ideas from above: Inthe include files for menus only have a structure for each menu (top and left) stored in a multidimensional array. Then create another file that holds the function to draw the menu (and possibly your other functions). Call a function … | |
Re: My personal opinion: If you have say 100 instances of the same application that could be a nightmare to maintain (bug fixes, upgrades...). You would be better of having one app (and one database) but you have to be careful to make each user's data and login secure. So particularly … ![]() | |
Hi folks. I have a strange thing happening here. I have a loop where counter gets incrememnted by 0.1 starting from 0 and up to 1. In each iterration I use the counter in an expression with modulo operator. I get incorrect result when the counter has values of 0.8 … | |
Re: Seems like $row['teacher_id'] and $row['comment'] haven't got a value. Insert the following after the line 19: if(!isset($row['teacher_id']) or empty($row['teacher_id']) or !isset($row['comment']) or empty($row['comment'])) { die('<pre>' . print_r($row, 1) . '</pre>'); } and post the output. (the code above will check if any of the suspicious values do not exist and … | |
Re: Firstly: you are mixing double quotes for PHP strings with double quotes for html attributes. Escape the later. Secondly: composite variables in a string should be enclosed in curly braces to get parsed correctly. $mesaj="<li><a href=\"{$db_field['Image']}\" class=\"pirobox\" title=\"{$db_field['Titlu']}\"><img src=\"{$db_field['Image']}\"/></a><p>{$db_field['Content']}</p><div class=\"button\"><pre><a href=\"index.php\">Read More</a><a href=\"{$db_field['Download']}\">Download</a></pre></div></li>"; | |
Re: Define is used for defining constants and constans once defined can not be changed (by another define). You can always test if the constant has already been defined: if(!defined('THIS_PAGE')) {define('THIS_PAGE', 'pagename')} ![]() | |
Re: Your code contains several statements of this form $var=bad-date; If you intended to assign a string `'bad-date'` to `$var` enclose it with quotes. Before displaying image you should then test the $var if it contains valid date: if($var != 'bad-date') { $imagepath="daily/$var.gif"; ... } | |
Re: Check also whether it is not empty: if(is_array($_SESSION['cart']) and !empty($_SESSION['cart'])) or check for elements one level below: if(is_array($_SESSION['cart'][$i]) and !empty($_SESSION['cart'][$i])) or check for elements two levels below: if(isset($_SESSION['cart'][$i]['productid'])) { $pid=$_SESSION['cart'][$i]['productid']; } else { echo 'No product ID!'; } ![]() | |
Re: To access fields of a row use associative index that mysql_fetch_array function returns: echo $row['Firstname']." - ".$row['Rank']; To address particular rows (using SELECT, UPDATE or DELETE queries) you have to use WHERE condition(s) that return just one row. In your case it would be a good thing to have another … | |
Re: IP of the machine browsing your script: `$_SERVER[REMOTE_ADDR]` If behind proxy (does not work always): `$_SERVER['HTTP_X_FORWARDED_FOR']` | |
Re: Just a dumb question: if you want to get active scripts why is the condition `WHERE active = '0'`? Shouldn't it be `WHERE active != '0'`? | |
Re: Invest i a good book like this one: http://www.amazon.co.uk/Absolute-Beginners-Experts-Voice-Source/dp/1430224738/ref=sr_1_49?ie=UTF8&qid=1345629495&sr=8-49 or more advanced one: http://www.amazon.co.uk/PHP-MySQL-Dynamic-Web-Sites/dp/032152599X/ref=sr_1_1?ie=UTF8&qid=1345629611&sr=8-1 learn from the resources on net: http://www.w3schools.com/php/default.asp http://www.php.net/ DANIWEB and set up a development environment and a server and start with simple scripts. | |
Re: More user friendly solution would be to offer movie IDs in a drop down list (html select element). In that case user can not select an invalid ID and they also do not have to remember all IDs (you can display movie names in the select element). Of course if … | |
Re: Check whether the query returns any records. Insert the following code between lines 7 and 8 and copy the output query in phpmyadmin: die("SELECT * FROM messages WHERE to_user = '$to_user' AND deleted = 'no'"); It could be that the variable `$to_user` has no value yet. | |
Re: From the error message one could conclude that the query returns 0 rows and therefore 1st row (index 0) can not be accessed. Please test the query with the actual parameters by inserting this code right after line 14: die("SELECT `logs_id` FROM `school_logs` WHERE `school_user` = '$school_user' AND `school_id` = … | |
Re: If page two is included in page one you can use variables from page one in page two straight away. If they are different variables they should have different names. | |
Re: Googled and found these: http://www.easyphpcalendar.com/ http://keithdevens.com/software/php_calendar | |
Re: You should put a test in the for loop to see whether the displayed number is the number of the current page; if yes then you have to have a code for displaying that number (and no link), otherwise you display a link. It is hard to give a snippet … | |
Re: The links above are referring to the named anchors (1, 2...) on the same page (hence #). The links above are constructed this way if they are on the page picture.php: <a href="#1">Picture 1</a> <a href="#2">Picture 2</a> or if they are on some other page: <a href="picture.php#1">Picture 1</a> <a href="picture.php#2">Picture … |
The End.