- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 34
- Posts with Upvotes
- 31
- Upvoting Members
- 25
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
98 Posted Topics
Re: I have the same requirement so I wrote a few lines that would demonstrate the answer to your question and give me a base to work from. <?php if (isset($_POST['submitted'])){ print_r($_POST); } ?> <html> <head> <script type="text/javascript"> function addTextArea(){ var div = document.getElementById('div_quotes'); div.innerHTML += "<textarea name='new_quote[]' />"; div.innerHTML += … ![]() | |
Re: I think you are confusing two file system types; localhost is for the browser address bar and relates to hostnames, but the script needs the system path. If 'install.php' is in the same directory, then you can try `'./install.php'` (./ is shorthand for this directory). You need to give the … | |
Re: @ricardojorge register.php line 35: `$r = mysql_query($q);` add some error checking: `if(!$r = mysql_query($q)) die(mysql_error());` do you get an error message? @lastmitch I agree with you, but I fancied the challenge and was already looking :) | |
Re: I copied your code into my own page and ran it and got a result with FF, IE and Chrome: object(SimpleXMLElement)#1 (1) { [0]=> string(5) "52.82" } Strange... | |
Hello :D I am using the twitter API to perform a search for a certain author, and storing the results in a database so that I can perfrom an action on each entry. However, there are many duplicate results that have small differences at the beginning of the string or … | |
Hello :) I'm working with a database of postcodes. I have an existsing query that returns the postcodes within a certain radius: `select *, acos(cos(51.496502411798 * (PI()/180)) *cos(-0.13982862499836 * (PI()/180)) *cos(lat * (PI()/180)) *cos(lng * (PI()/180))+cos(51.496502411798 * (PI()/180)) *sin(-0.13982862499836 * (PI()/180)) *cos(lat * (PI()/180)) *sin(lng * (PI()/180))+sin(51.496502411798 * (PI()/180)) *sin(lat … | |
Re: Hey GraficRegret, welcome to Daniweb :) Your description sounds like a typical use of PHP and MySql, but what help do you specifically need? Is there some code you need some assistance with? Are you looking for general considerations and tips from those who already walked that road? ![]() | |
Re: There are probably better ways, but I would make a temporary database with mysql and store them in there for easier manipulation. I would write a script to insert a few hundred at a time, and add the records gradually to avoid PHP execution limit, with an echo for every … | |
Re: I see the problem: `function validateForm(Qform)` expects a parameter passed with the function call, but you pass nothing: `onSubmit="validateForm();` change it to: `onSubmit="validateForm(this); return false;"` and it should work okay. | |
Re: Your database section looks a little mamlformed, specifically this line: `while ($query !=-1 && $row = mysql_fetch_assoc($query)) {` I would guess that the previous line: `$values = mysql_fetch_assoc($query);` already collected the necessary information, so if this line: `echo print_r($values, true);` prints the correct information, I would try changing your code … | |
Re: Line 32: `$sql="INSERT INTO tbl_candidate(email_id) VALUES('$email_id1');` has a missing quote before the semi-colon. Line 39: `else{` is missing the preceding curly brace. Fix those, see what happens. | |
Re: `if(isset($_POST['id']) && ($row['bankID'] == $_POST['id']))` or, `if(isset($row['bankID']) && ($row['bankID'] == $_POST['id']))` depending which key is not set. It's good that you have all errors showing. | |
Re: This hurts me more than it hurts you, but... [Let me google that for you!](http://lmgtfy.com/?q=what+is+json%3F) | |
Re: Welcome to Daniweb **albertsibanda9** :) The long answer: [Read This Before Posting A *second* Question](http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question) The short answer: Post your code before LastMitch gets hold of you :D ![]() | |
Re: check for result if($result = mysql_query("SELECT * FROM table")){ while ($row = mysql_fetch_array($result)){ // don't echo immediately, store in $string $string .= '["' .$row[1]. '",' .$row[2].'],'; } // now $string has an extra comma... $string = substr($string, 0, -1); } use [substr()](http://uk3.php.net/manual/en/function.substr.php) to select all but last character, then echo … ![]() | |
Re: > but i want to show the error in such a way that name of the tables couldn't be shown... Is that all? `$query = mysql_query("DELETE FROM table_2 WHERE tchr_id='".$id."'") or die("Oops, we have a problem, please contact the administrator.");` Change message to suit. | |
Re: `$alert_error = "<script type=\"text/javascript\"> alert('".mysql_error()."') </script>";` In the above line you are referencing `'mysql_error()'`, but it doesn't exist yet because you did not run the query that produces the error. Also, you wanted Javascript to alert the value of `'mysql_error()'`: if (!$query = mysql_query("DELETE FROM abc WHERE id ='$id'")){ echo … | |
Re: This is simple maths, use parentheses to force calculations in correct order: `field3 minus (field1 divided by field2)` $result = ( $row['field3'] - ($row['field1'] / $row['field2']) ); echo "<td>".$result."</td>"; | |
Re: There are probably better ways, but If I had to achieve it with existing knowledge, I would do something like this: $wordString = $_POST['search']; /* first test there are comma separated values */ if (strpos($wordString, ",")){ /* split string into array of strings on the comma */ $words = explode(",", … | |
Re: @kevinp2012 seriously, are you asking the OP to improve **his** English? @dodgers125 I'm not *sure* what you want but maybe I can give some pointers about your code: <!-- header row, the 1 must be in quotes: border="1"--> <table border="1"> <tr><th>Sale Number</th> <th>Item</th> <th>Item Cost</th> <th>Units Sold</th> <th>Sale Cost</th> </tr> … | |
Re: Using javascript: <head> <!-- You must have the id set in the next line --> <link id="stylesheet" rel="stylesheet" type="text/css" href="default.css" /> <script type="text/javascript"> function switchStyle(el){ //get selected theme var styleSheet = el.options[el.selectedIndex].value; //apply the new style using id set earlier. document.getElementById('stylesheet').href = styleSheet; } </script> <body> <!-- (this) refers to … ![]() | |
Re: I believe we have two insert types with MySQL: `"INSERT INTO tablename set field='value', column='amount'..."`, and `"INSERT INTO tablename (field, column) VALUES ('value', 'amount')"` But your query is a mixture of both and neither: `"INSERT INTO ".$table." values $fld='$this->add_security($val)'"` | |
Re: `$check= mysql_query("SELECT FROM accounts WHERE (email='".$email."')");` Select what from accounts? ALL, Id etc? I guess error checking the query would have given an error. | |
Re: **@xbat**, from what I can see, `'q'` is not defined in your JS code, it is not even referenced, so it can't be JS that's giving the error. The only way I can understand this undefined error regarding 'q' is the processing page, testwopart1.php. The beginning of the script (testwopart1.php), … | |
Re: A standard array of checkboxes: <input type="checkbox" id="unicycle" name="cycle[]" value="1">I have one wheel. <input type="checkbox" id="bicycle" name="cycle[]" value="2">I have two wheels. <input type="checkbox" id="tricycle" name="cycle[]" value="3">I have three wheels. Now, echoed with PHP: <?php //escaping the double quotes: echo "<input type=\"checkbox\" id=\"unicycle\" name=\"cycle[]\" value=\"1\">I have one wheel."; //using single quotes: … | |
Re: It may well be possible to get all the things you want in one query, using the Join technique, but that is for someone else to tell you, have a look [here](http://www.daniweb.com/web-development/databases/mysql/threads/437575/combine-two-queries-into-one) :D As for looping through the way you mentioned: <?php $cityArray = new array(); $sql = "SELECT city … | |
Re: **vaultweller123** is exactly right. If you declare a variable: `$variable = "value";` ...and then you declare the same variable with a different value: `$variable = "another value";` ...the variable holds the second value and the first value is lost. It is the same in your loop, your variable '$url' can … | |
Re: I read through the code you posted, it was messy and I felt dirty and soiled :D But your question is: > any idea how to pass the selected data to the backend page once i click submit ...?? ...and my answer is yes, I have plenty idea, and I … | |
Re: I don't see how the hidden input can possibly be populated with the intended value because it is PHP that echoes the value and PHP won't do anything once the page is loaded. `$_POST['brand']` needs to exist when the page is loaded for PHP to echo the value onto the … | |
Re: I answered the same question yesterday so I can just copy and paste :D You need to make sure all your form elements are contained within a form declaration: <form action="page_that_will_process_form.php" method="post"> <input type="text"... /> <input type="button"... /> </form> Make sure each input has a unique name. <input name="unique_name"... /> … | |
Re: It means that Invalid arguments were passed to the implode function on line 40 of the /home/tjconsul/public_html/admin/actions/act_addcandidate1.php file. Show your code. | |
Re: Was your code hit by a truck? #nav ul { width: 100%; float: left; margin: 0 0 0 0; padding: 0; list-style: none; background-color: #fff; position: absolute; top: 162px; left: 550px; } You have 100% width AND absolute positioning, I guess the unecessary whitespace is 550 pixels. | |
Re: `if (user.lenght<5)` <-- typo of the word length. There may be other things, but your code is so messy I need to format your nested loops to make any sense of them. There is a great article here regarding the format of your code and loops: http://phpmaster.com/practical-refactoring-1/ | |
Re: Both of your functions have the same name, so presumably the second version is overwriting the first one, meaning that really there is only one function - the second one. Did you try to name the two functions differently and add both functions to the onclick event of the button? … | |
Re: That JS line that produces the radio group has gone horribly wrong :D The best way forward is to look at the exact syntax of a static radio group: <input type="radio" name="overall" value="0">0 then escape the double quotes: <input type=\"radio\" name=\"overall\" value=\"0\">0 then put it inside the document.write function: document.write("<input … | |
Re: `$num=mysql_numrows($result)` is wrong, it should be: ` mysql_num_rows($result);` How strange that the script tests that $query exists (which is a string that is defined the previous line), then sends the query to the DB without any error checking: `$result=mysql_query($query);` | |
I have two tables, author and quote: author: AID, Name, YOB, YOD. quote: ID, AuthID, Content. I currently get all the authors with one query and as I loop through them, I run a second query to get the count of quotes that have the current AID: $sql = "SELECT … | |
Re: The [...] after the variable is not necessary with PHP, so it's `foreach($_POST['check'])` | |
Re: There could be a problem with your UPDATE statement. I recommend using error checking with all database transactions, for a great guide look here: [mysqli with error checking](http://www.daniweb.com/web-development/php/code/434480/using-phpmysqli-with-error-checking) If your variables are of string type, your update should look like this: `"UPDATE tablename SET column='value' WHERE id='value'"` I know you … | |
Re: You have two options - 1. Use Javascript to verify that both passwords match (and the rest of the form is completed correctly) before the form is submitted. Your script appears to be configured that way looking at this line: `<form name="registration_form" method="post" action="register.php" onsubmit="return Validate();">` 2.Use PHP to check … | |
Re: I copied your situation and tested the code on my own wamp server and it worked fine. I moved the include file above the document root and it still worked okay. This wamp server is so sensitive it throws an error if I look at the screen funny. | |
Re: $query = mysqli_query($con, "SELECT id,price FROM edit WHERE id=$res"); ...this was correct, but lacked the 'ORDER BY' clause, so : $query = mysqli_query($con, "SELECT id, price FROM edit WHERE id=$res ORDER BY id"); ...is all that needed changing, but when urtrivedi changed it to: WHERE id='{$_GET['res]}' ...it went horribly wrong … | |
Re: > I am trying to create a **form** that updates mySQL-database. Where is the form? | |
Re: $data = "$firstname ; $lastname ; $mood ; $datestring : $timestring\r\n"; | |
Re: Hey, I liked the challenge, so I tried it out. //in the head section: This function makes the text input elements depending on the number selected in the options. <script type="text/javascript"> function makeInputs(amt){ var str=""; for(i=0;i<amt;i++){ str += "<input type=\"text\" name=\"text_" + (i+1) + "\"" + " id=\"text_" + i … | |
Re: It may already be, but your CSS src needs to be relative to your index - [include paths](http://stackoverflow.com/questions/7378814/are-php-include-paths-relative-to-the-file-or-the-calling-code) You can also try an absolute path as a debug test. | |
Re: What if you use your friend's details on the PC that works for you? What if your friend uses your details on his machine? What if your friend changes his $_GET['dir'] variable to 'mottram' in the URL? Did you create the upload directory manually or let the script create it? … | |
Re: [mod rewrite](http://www.sitepoint.com/guide-url-rewriting/) | |
Re: a tablename that consists only of digits may need to be encapsulated with \``backtick`\`s - look [here](http://stackoverflow.com/questions/676451/are-you-allowed-to-use-numbers-as-table-names-in-mysql) | |
Re: [strrpos()](http://uk3.php.net/manual/en/function.strrpos.php) |
The End.