-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
$id = _GET ['id']; Not Working :/ Please Help.... URGENT!
Ch0cu3r replied to davidfattore's topic in PHP Coding Help
Is there a .htaccess file in the root of your site? and is there code like RewriteEngine On and RewriteRules defined in that file? If there is then mod_rewrite is being used. Can you post the RewriteRules here. I have feeling the rewrite rules are not passing the query string. -
$id = _GET ['id']; Not Working :/ Please Help.... URGENT!
Ch0cu3r replied to davidfattore's topic in PHP Coding Help
Are you using mod_rewrite? -
$id = _GET ['id']; Not Working :/ Please Help.... URGENT!
Ch0cu3r replied to davidfattore's topic in PHP Coding Help
Add this to your code printf('<pre>%s</pre>', print_r($_GET, true)); What does that output? -
Counting characters in a string and replacing it
Ch0cu3r replied to therocker's topic in PHP Coding Help
You'd add those words to an array, then loop through them, get the words length using strlen(). Then use str_repeat() to create a string of astrics that is the length of the word to filter. Something like foreach($filter_words as $word) { $replacement = str_repeat('*', strlen($word)); $text = str_replace($word, $replacement, $text); } -
$id = _GET ['id']; Not Working :/ Please Help.... URGENT!
Ch0cu3r replied to davidfattore's topic in PHP Coding Help
What url are you using to access that page? $_GET['id'] will only work if your url is like site.com/page.php?id=123 -
$result->fetch_array($result); needs to be $record = $result->fetch_array(MYSQLI_ASSOC); Read the manual on mysqli fetch_array http://us2.php.net/mysqli_fetch_array
-
The include is not the issue. Its this $result = $link->query($sql)or die('Cannot select the database'); That is what is causing the error. Delete it.
-
Generate value that doesn't exist in table
Ch0cu3r replied to adamrcarlson's topic in PHP Coding Help
Running queries within loops is not very efficient. You could select all codes from the database and then add them to an array. Then use PHP to loop through that array checking to see if the new code exists, if does regenerate the code and check again. Only add the code to the database when the code doesn't match. Something like function getCodes() { $code_string = "SELECT code_number FROM Codes"; $code_result = mysqli_query($a_con, $code_string); $codes = array(); while($row = mysqli_fetch_assoc($code_result)) { $codes[] = $row['code_number']; } return $codes; } function generateNewCode($codes){ // generate code $report = rand(100000000, 999999999); // check that it exists if(in_array($report, $codes)) return generateNewCode($codes); // it exists, call this function again, generates a new code else return $report; // Code doesn't exist, return the generated code } $codes = getCodes(); // get codes from database $report = generateNewCode(&$codes); // generate a code -
It because of this here <?php include ("mySqli_conn.php"); $result = $link->query($sql)or die('Cannot select the database'); What query are you trying to run here. Basically $sql is either empty or not defined. So you are getting the Empty query error message. Is this for selecting the database to use? If its you tell mysqli what database to use when you connect. $link = new mysqli('hostname', 'username', 'password', 'database name'); // object // OR $link = mysqli_connect('hostname', 'username', 'password', 'database name'); // procedural
-
Is this code being ran in a loop? if it is then it'll update every row to the same destination value. You will need to the records id to a hidden form field. You will also want to move the code for updating the record outside of the loop. Code for displaying the destination value or edit form if($destination=='') { echo "<form method='post'> <td width='25%'><center> <input type='hidden' name='id' value='$id' /> <input type='text' name='destination_save2' placeholder='Destination Location' /> <input type='submit' name='submit2' value='Update Call' /></center> </td>"; echo "</form>"; } else { echo "<td width='25%'><center>$destination</center></td>"; } Then outside of the loop you'll have the update code if(isset($_POST['submit2'])) { $id = (int) $_POST['id']; $destination_save2 = mysql_real_escape_string($_POST['destination_save2']); $result8=mysql_query("UPDATE uc_calls SET destination='$destination_save2' WHERE id=$id"); if(!$result8) { die('Failed to update call. Please contact your Technical Analyst with this error:<br />' .mysql_error()); } else { header("Location: ?"); } }
-
What is your current code. All it should require is a simple if/else if($var == 0) { // Yes (banned) } else { // No (not banned) }
-
Maybe body, .all { /* styles applies to both <body> and class="all" */ }
-
Your code should be $lines = array(); $lines[] = array('description'=>$desc1,'qty'=>$qty1,'rate'=>'11.70'); $lines[] = array('description'=>$desc2,'qty'=>$qty2,'rate'=>'13.25'); $line_items = array($lines); printf('<pre>%s</pre>', print_r($line_items, true)); If you want each item in $lines to contain an array description, qty and rate items, In other words multi dimensional array.
-
Maybe you should rethink your logic. The variables $Output and $Output1 are only defined when the variable $_POST['Code'] exists, In other words when the form has been submitted. Obviously you want these variables defined when the form has not not been submitted so the user can give an answer to your sum. However that is only one part of the problem. The next issue you'll face is how are you going to know the user gave the correct answer to the sum? The variables $Output and $Output1 will not be remembered. You'll need to pass on the answer to the sum (either as a hidden form field or as a session/cookie value), so when form has been submitted your code can validate that the user gave the correct answer.
-
MySQL does not sort arrays. It sorts the data that is returned from your query criteria. Only until your use msyq_fetch_* function it converts the data into a format that is usable by PHP, in your case an array. You should be very careful when using eval it could become to major security issue if you do not handle it correctly. What you could do is change your query to this $sql="SELECT `Order ID`, REPLACE(`Price`, '$marketrate', $marketrate) as MarketPrice from `table` ORDERBY MarketPrice"; This will replace $marketrate in Price field to the value of the $marketrate variable. And then it'll sort the results by MarketPrice. However I don't think it'll also perform mathematical sums too like $marketrate*1.02.
-
What undefined variable are you getting? Post the error message(s) in full here.
-
Yes, then in the mailresetlink function you use the $to variable not $email2
-
Ajax using Php is not working properly and also showing a notice.
Ch0cu3r replied to vivek2tech's topic in Javascript Help
You are getting the notice because the $_GET['q'] variable doesn't exist until the ajax request. You need to check that q exists in the $_GET superglobal before you use it. Is that code all from getuser.php? If it is you need to isolate the code that should respond to the ajax request, for example you only want the users details (the table), Not the whole webpage for getusers.php. Otherwise your webpage will duplicate. The objective is to allow someone to select a user from your dropdown. What will happen is someone will select a user. The javascript code will then perform an ajax request to getuser.php and set the q query string variable to the selected users id. The PHP code will then fetch the users details that matches the id value in $_GET['q']. It'll then output the users details in a table. What is outout from getusers.php is used as the response. The response from the ajax request will be contained in the xmlhttp.responseText variable. You then add the response to the <div id="txtHint"></div> This is how you would setup your code. <?php // check that $_GET["q"] exists (ajax request has started) if(isset($_GET["q"])) { mysql_connect('localhost', 'root', ''); mysql_select_db("sample"); $q = mysql_real_escape_string($_GET['q']); $sql= "SELECT * FROM user WHERE id = '".$q."'"; $result = mysql_query($sql); echo "<table border='1'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close(); exit; //We only need to echo out the data we need for the request (this will be the response) } ?> <html> <head> <script type="text/javascript"> function showUser(str){ if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; /* the response */ } } xmlhttp.open("GET", "getuser.php?q=" + str, true); xmlhttp.send(); } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="1">Peter Griffin</option> <option value="2">Lois Griffin</option> <option value="3">Glenn Quagmire</option> <option value="4">Joseph Swanson</option> </select> </form> <br/> <div id="txtHint"> <b>Person info will be listed here.</b> </div> </body> </html> -
If $email2 contains the email address you want the email to be sent to then you should be passing it to the mailresetlink function, not the $email variable. if(isset($_GET['email']))mailresetlink($email,$token);
-
Wrong forum. Post it in the CSS Help forum
-
Call PHP Function from within another function
Ch0cu3r replied to reptile's topic in PHP Coding Help
onchange doesn't cause the page to refresh, So no request is being sent to the webserver (unless you have some javascript code that is refreshing the page).- 14 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Call PHP Function from within another function
Ch0cu3r replied to reptile's topic in PHP Coding Help
Yes, but what code do you think is being executed when those functions are called using onchange a) Javascript, b) PHP or c) both?- 14 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Set a session variable after you call mail(). Check that this variable doesn't exist before you send the email. If it does then display an error or redirect the user to another page.
-
Call PHP Function from within another function
Ch0cu3r replied to reptile's topic in PHP Coding Help
The browser is calling that function. Not PHP. Do you understand the difference between Javascript and PHP? And how/when these two languages are executed?- 14 replies
-
- php
- javascript
-
(and 2 more)
Tagged with: