812 Posted Topics
Re: Provided that $result has one element less than $productItems: foreach($productItems as $key => $item) { if(isset($result[$key])) { $productItems[$key]['price'] = $result[$key]; } } | |
Re: Code for the last button: <div class="buyOrSellBox"> <input id="memberRoleIntlBoth" value="both" onclick="document.getElementById('userrole-error').style.display='none';changesubmitbtnname('yes');" name="userrole" style="border: 0px none ;" type="radio" <? // the condition is: // if $_REQUEST['userrole'] is not set (none of the radio buttons have been chosen) // or the 'both' radio button has been chosen // then make it checked … | |
Re: A few notes here: 1. You mix GET and POST method. From URL it seems like your intention is to use GET, from the code it seems like you wanted to use POST; it is nothing wrong with mixing methods but do not do it if not realy needed since … | |
Re: First start the table and add a header row: <table > <tr><th>Product ID</th><th>Items</th><th>Price</th><th>Date</th><th>Action</th></tr> Then add the rows with data: <?php while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["name"]; $details = $row["details"]; $size = $row["size"]; $price = $row["price"]; $quantity = $row["quantity"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); echo "<tr>"; echo … | |
Re: Escape the values in the query using your databases's escape function. If you use mysqli the function is [mysqli_real_escape_string](http://php.net/manual/en/mysqli.real-escape-string.php) (or mysqli::real_escape_string if you do it OOP way). $query = "UPDATE room SET floor='" . mysql_real_escape_string($room->floor) . "' where id=room->id"; | |
Re: Insert a temporary debug code. It is simple but it often helps. Test the displayed query in phpmyadmin or post it here. <?php include "dbConfig.php"; $Y=$_POST["Y"]; $query="INSERT into tbl_subjectsenrolled (SubjectID) values ('".mysql_rel_escape_string($Y)."')"; // Temp DEBUG code die($query); mysql_query($query) or die (mysql_error()); ?> | |
Re: You need to use client side (which is most often javascript) to detect screen size. Have a look at this link: http://www.javascriptkit.com/howto/newtech3.shtml How to utilize that with php? Maybe using Ajax, something like this (I use jquery [load](http://api.jquery.com/load/) here): <script type="text/javascript"> // URL to open var myUrl = ''; // … | |
Re: Looking at source of your page two errors show up in Firefox on Ubuntu: - the comment line `<!----Car Image -->` is not structured correctly (my FF says *-- is not permitted withim a comment*) - it also doesn't like the line `<div class="ui-widget">`. It is probably not allowed there … | |
Re: The [mysql_query](http://php.net/manual/en/function.mysql-query.php) function returns a resource not a row. The resource is a special php type that can be used to retrieve rows. You can use the mysql_fetch_row() function to fetch rows while ($row = mysql_fetch_assoc($cat_name)) { echo $row['cat_title']; } Please note that $cat_name is a misleading name for a … | |
Re: On line 15 more appropriate check would be: if (isset($_POST['id']) && is_int($_POST['id'])){ so you are checking whether $_POST['id'] exists at al and is integer. | |
Re: You should pass your getLink function connection parameters since it can not access variables out of it's scope: function getLink($serverName,,$userName,$userPassword,$nameOfDataBase){ $link=@mysqli_connect($serverName,$userName,$userPassword,$nameOfDataBase); if(!$link){ echo "connection Error".mysqli_connect_errno(); } return $link; } ![]() | |
Re: It is hard to figure out from your post what exactly is the problem but looking at your query on line 6 this certainly won't work: if ($ser<4) $sql .= " AND pulse_channel=$serv[] "; You can't use $serv[] a query (which is basicaly a string). You will either have to … ![]() | |
Re: Also there are tags missing like `<form>`, closing `</td>` and `</tr>` and `<table> </table>` pair. But main error is as *pixelsoul* pointed the missing curly bracket. | |
Re: [phpacademy](https://phpacademy.org/) if you prefer watching videos. You will also find tutorial for mysql there. PHP comes to it's power if you dynamicaly use data from a database (and mysql is most often used). | |
Re: Where do you get the list of questions to be displayed? In any case it is probably an array of question ID's which you have to iterate through. // array of question IDs to be displayed // I just made them up for this example $q_id_arr = array(1,2,3,4,5); // loop … | |
Re: I think it's got to do with the fact that Joomla is written following the MVC pattern. All the processing and database access is done somewhere behind (model / controller) and the result is displayed thorugh single index.php page (affected also by a template). On their site they say: Joomla! … | |
Re: On line 8 you should probaly have a space before WHERE $query_update .= " WHERE `item_id`=".$_POST["item_id"]; and the comma on line 7 should not be there (before the WHERE): $query_update .= "`item_avai`='".$_POST["item.avai"]."'"; The easiest way to check is to insert a debug code between lines 8 and 9: die($query_update); which … | |
Re: Can you clarify this: you have a table C_Search containing a set of keywords. Do you want to search by all of them or just a few of them? | |
Re: You basically need another ajax call passing values to a php script that will insert/update database. | |
Re: The first while loop has no code since you did not use any curly brackets. Is this suppose to be like that? Or would be more correct like this: while (osc_has_categories ()) { // check category id and name inside while loop is ok! echo osc_category_id(), ": ", osc_category_name() ; … | |
Re: I assume the `/home/delhioia/public_html/facebook/index.php` file is being included from `/home/delhioia/public_html/index.php`, right? The error message says that `/home/delhioia/public_html/index.php` is sending output on line 7, probably before inclusion of the `/home/delhioia/public_html/facebook/index.php` that is why the error, I presume (provided that my assumptions are right). | |
Re: Do the values come from the $nume_produs[1] and $key variables? Where do they get assigned and what from? | |
Re: 1. It assigns a value to $username variable, using EscapeCharacters() method of a $secure object (it is an example of object oriented PHP) to escape characters. $secure is an object derived from some class that is obviously designed to deal with user (form) input at login. There must be an … | |
Re: <?php // you have your subject $subject = ...; do it in php: // echo this in appropriate place in html (betwen <head> and </head> tags) echo '<meta name="description" content="' . $subject . '">'; echo '<title>' . $subject . '</title>'; ?> or in html: <meta name="description" content="<?php echo $subject; ?>"> … | |
Re: Is web server configured to serve PHP? Can you show the code of the html file? | |
Re: Just one question: why do you store the $_POST array in session? What is the exact purpose of that? Tipically the code goes like that: - you have a form wrapped within <form> and </form> tags (you do not have that, any reason why not?) - in the opennig <form> … | |
Re: You can save values in a txt file, JSON format would be a good one. You can use [json_encode](http://php.net/manual/en/function.json-encode.php) and [json_decode](http://www.php.net/manual/en/function.json-decode.php) functions. Instead of JSON you can just serialize data into a txt file. | |
Re: And an excellent resource for web apps security is OWASP and their [Top 10 cheat sheet](https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet). Go through their list. | |
Re: Maybe not the most elegant solution but it works. <?php // connect to DB ... // run an endless loop while(1) { // generate unique random number $randomNumber = rand(0, 999999999); // check if it exists in database $query = "SELECT * FROM tbl_rand WHERE the_number=$randomNumber"; $res = mysql_query($query); $rowCount … ![]() | |
Re: Why do you store contents in database? You could just save a file in a directory and let users downolad it from there. If it is really necessary to store the contents in database I think the field type should be binary. I am not sure if you can recreate … | |
Re: Another way of doing it: Frst initialize the variables to empty string: $search_policy = ''; $search_surname = ''; $search_name = ''; Then you assign a condition to any of the variables if $_POST element exists, as you have done it. On lines 43 to 45 chremove the else bit from: … | |
Re: And also post a few sample rows of csv file, especially the ones that cause problems. | |
Re: The form does not have to be loaded from a separate php file. It can be in a div that is initially hidden (say the id is form-container) and when the user clicks the *Add News Item* link the div is shown using jquery [show()](http://api.jquery.com/show/) method. $(document).ready(function(){ $("#news").click(function(){ $("#form-container").show(); }); … | |
Re: Display the queries and check them in phpmyadmin (and post here if you do not find an error). Insert this code after line 46 but before the closing curly bracket: echo "SQL: $sql<br>SQL1: $sql1<br>SQL2: $sql2<br>SQL3: $sql3<br>SQL4: $sql4"; | |
Re: On line 14 ('$_POST[title]',''$_POST[discription]','$_POST[content]')"; you have two single quotes so the query syntax is wrong. Remove one of them. Edit: haven't noticed that LastMitch has already pointed that out, sory. | |
Re: Looks like the `else` statement on line 54 hasn't got a closing curly bracket. I you put one say on line 73 the error is gone. Double check though if that is the intended place for it. | |
Re: You can create radio buttons with PHP. Put categories in an array, cycle through it, add code for radio buttons and check if current category matches the one from the DB: <?php // array of categories (you can always edit it and the radio buttons will change) $categoriesArr = array('Action', … | |
Re: The trouble is in your first line: // index.php <?php session_start(); ob_start(); ?> You use php comment outside of `<?php ?>` block so it is not treated as php code but as html code. That means that you send html before calling session_start() and ob_start() which is incorrect since both … | |
Re: Each input on your form has to have a unique ID so you can refer to it. Also edit links have to have uinque IDs. You can use an ID from the database data or something else. <input name="tx_name" type="text" id="tx_id-<? echo $data['id']; ?>" size="35" value="<? echo $data['title']; ?>"/> <a … | |
Re: Let me repeat to see if I understood: You want to generate unique keys yourself (IOW mysql autoincrement is not OK for your purpose). What is the format of the key and what are the rules for constructing the key? > then the new one created key must be from … | |
Re: On line 5 you are assigning the same value to $result over and over again. $result = mysql_query("SELECT * FROM tag WHERE point='$pagename'"); so `while($row = mysql_fetch_array($result))` condition is always true (it is always first row of the table). I would remove line 5. The $result on line 9n is … | |
Re: $query = "SELECT SUM(quanitity) FROM `tablename` GROUP BY `year`"; Backquotes might also be important if you use names that are same as mysql keywords. | |
Re: You are returning only the name in a message not alsoo the lastname. Add lastname also and separate the name and lastname so you can distinguish them when returned from ajax cal, maybe with comma: ... while($nt=mysql_fetch_array($t)) { error_reporting(0); $msg.= $nt[name] . ',' . $nt[lastname]; } } echo $msg; On … | |
Re: Are you sure the second and third SELECT keywords have to be there. Would this be OK: $bquery="SELECT * FROM rt_booking WHERE rt_unit_id='".$_POST['unit_id']."' AND (UNIX_TIMESTAMP(str_to_date(rt_start_date,'%Y-%m-%d'))>=".$my11." OR UNIX_TIMESTAMP(str_to_date(rt_end_date,'%Y-%m-%d'))<=".$my22.")"; | |
Re: Put this temporary debug code on line 3: die("UPDATE $title SET arole = CONCAT_WS(',', arole, '$name') WHERE op = '$name'";); Your query will get displayed with actual values. Copy it to the SQL window of phpmyadmin and see what you get when you run it. If there are errors you … | |
Re: I quickly put together this recursion function. function assoc2indexedMulti($arr) { // initialize destination indexed array $indArr = array(); // loop through source foreach($arr as $val) { // if the element is array call the recursion if(is_array($val)) { $indArr[] = assoc2indexedMulti($val); // else add the value to destination array } else … | |
Re: Check for existence of image in the DB table and if exists asign it to $logo variable otherwise assign a placeholder to $logo variable. Then display whatever is in the $logo. <?php if(isset($row_getListing['image'])) { $logo = $row_getListing['image']; } else { $logo = 'placeholder.jpg'; } ?> <div id="logo"><img src="images/<?php echo $logo; … | |
Re: Put this code immediately after line 68: die("INSERT INTO file_records (file_name, file_title, file_size, uploaded_date) VALUES ('$NewFileName', '$FileTitle',$FileSize,'$uploaded_date')"); It will display the query as it gets contructed using the variables. Paste it into phpmyadmin and check for errors. You can also post it here. BTW: none of the data in the … | |
Re: I have actually used PEAR a lot but it was on Linux machine. The Windows part of installation instruction is http://pear.php.net/manual/en/installation.getting.php . I had no problems installing it and using it in Linux nd I think it should work equally fine in windows. BTW if you are just after one … | |
Re: It seems like there are no fields with those names in the pedagogu table. Can you check whether you have spelled the index names correctly and same as field names (sorry to bother you with one more check but nothing else seems to be incorrect). You can also try to … |
The End.