davidannis
-
Posts
627 -
Joined
-
Last visited
-
Days Won
2
Posts posted by davidannis
-
-
@davidannis, who's your dad?
Mr. Annis, of course.
-
use the examples you found to count the ones and then to count the twos and add the two results.
$number_of_ones_and_twos=$ones+$twos;
if you try it and have trouble, post your code and we'll help.
-
Same issues here
<input type=submit name=submit value=Remove<
You should code in an IDE that will color code things and highlight mistakes. I use netbeans which is free and can be found at netbeans.org
.
-
This is wrong
<form action=bills.php method=POST<
No quotes around bills.php or POST, no > to close form tag.
-
My son wrote this (with a little help from his dad):
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Calculator</title> </head> <body> <p> <form method="POST" action="Calculator.php"> <input type="text" name="x"><br /> <select name="operation"> <option value="+">+</option> <option value="-">minus</option> <option value="*">*</option> <option value="/">/</option> <option value="sqrt">square root</option> </select><br /> <input type="text" name="z"> <input type="submit"> </form> </p> <?php switch ($_POST["operation"]){ case '+': $answer=$_POST['x']+$_POST['z']; break ; case '-': $answer=$_POST['x']-$_POST['z']; break ; case '*': $answer=$_POST['x']*$_POST['z']; break ; case '/': $answer=$_POST['x']/$_POST['z']; break ; case 'sqrt': $answer=sqrt($_POST['x']); break ; } echo $answer; ?> </body> </html>
any errors are mine.
-
Why would you bother escaping an integer? Just make it an int.
How do I know that id is an integer? Probably is but I don't think that you can tell from the code. If it is an integer and is never going to change to a string then you are right making it an int will be faster.
-
remember to sanitize your data
$id=mysql_real_escape_string($_POST['id']; DELETE FROM ... WHERE id = $id;
to protect against sql injection attacks
-
I missed that. mac_gyver is right. You need to fix both issues.
-
You are missing a closing curly brace }
-
Try enclosing the values in quotes:
$write = "\"$FirstName\", \"$LastName\", \"$Age\"\n";
-
Muddy_funster is right. You can set the error message in the loop and echo the error message after the loop completes:
while(false!== ($file = readdir($res))) { if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) { if (($info["extension"] == "mp3") || ($info["extension"] == "wav")) { }elseif(!isset($errorMsg)){ $errorMsg = "Your Error Message"; } } }// now we are out of the loop if (isset($errorMsg)) echo $errorMsg;
-
I can't see the error. Does error reporting tell you anything?
-
I was going to re-write this for the OP since he's trying, but before I do I have something that's puzzling me. Can anybody explain why this:
$construct .="title LIKE '%Funny%'";
is not what I expected, which would have been this:
$construct .="title LIKE '%$funny%'";
which I would have rewritten as:
$construct .="title LIKE '%".mysql_real_escape_string($funny)."%'";
I'm clearly missing something.
-
I don't see where your variable, such as $varFirst are assigned values.
-
$construct contains unsanitized user input. It is easily exploited in an SQL injection attack. You need to sanitize the data. You can use http://php.net/manual/en/function.mysql-real-escape-string.php to do so. If you try to write the code, we'll help but we won't write it for you.
-
Not sure how to sanitize $construct because we don't see how it is built but for $id or $per_page something like
$id=intval($_REQUEST['id]); if ($id<1){ echo "error message about starting with an id that is at lest one'; // or redirect to an error page die(); }
-
The @ before the mail suppresses error messages. I would remove it for testing at least. Is the body of the e-mail completely blank? Did it ever work? Is the subject line blank?
-
Assuming that $id and $per_page are not passed in the URL/form and $construct is properly escaped it is fine. We'd need to see how those variables get values to be sure.
-
I would put something like this on the third line right below the line that starts $code=
if ( $code!='' ) { header ("Location: http;//mydomain.com/myscript.php?code=$code"); exit; }
-
I can't follow what you are doing. Looks to me like you do the same thing in your if{} and your else{} Then you create a function that returns nothing. Sorry I can not help more.
-
If I am understanding you correctly you are trying to total the $totalPayment column. Try replacing this
<?php } while ($row_rsTenProp = mysql_fetch_assoc($rsTenProp)); ?>
with this:
<?php $grandTotal+= $totalPayment; } while ($row_rsTenProp = mysql_fetch_assoc($rsTenProp)); ?>
and this
</tr> </table>
with this:
</tr> <tr><td>Grand Total:</td><td><?php echo $grandTotal;?></td></tr> </table>
If that works you will want to format the number and make the columns look pretty.
-
try
if($session->isAdmin()) {$query="SELECT username FROM users WHERE `username` !=' ADMIN' ";}
-
What are you trying to loop through? Looks like you are trying to read database records but I don't see where you open a database or select records. Do you open a database someplace else and you just didn't post that code?
-
($totalPayment = ($row_totalPayment))
I think where $row_totalPayment comes from but if you want to see if it equals $totalPayment you need == not =
I also can't figure out what you are doing with this
{ $row_totalPayment; }
simple summation program
in PHP Coding Help
Posted
Hopefully, if it's not one of the operations my 7 year old coded the OP can add another case to the switch statement. If not, perhaps my son can do it as a freelance job.