![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
AyKay47
-
Posts
3,281 -
Joined
-
Last visited
-
Days Won
1
Posts posted by AyKay47
-
-
So, what you suggest me to correct? Its good you are telling me my mistakes...as I want to correct myself...
The FILTER_VALIDATE_INT is doing its job well, I tested it... Huhh, for the striplashes, I have heard that turning Magic_gp ON is not recommended. For the '@', I see that doing that would not display the line if an error occurs. Well, I have learnt all of these in PHPAcademy, you know that guy who always do tutorials on YouTube...
Please, suggest me one by one about which to correct... and what I should do.... Thank you for telling my erros..its important to me to learn
Pika has kindly laid out a list of things that should be done differently for you.
Take the time to research each of these things and solve them yourself.
-
It seems that in your case, all you need to do is to move the <select> element inside your <form>, and possibly add action="POST" to the <form> also.
Err. method="post"
Not action
-
Thanks for the reply, I have tried what you suggested and I am directed to an error page when I go to bob.html
Do both files exist in your server? The example was pseudo code.
-
I tried this, but nothing:
mysql_query("UPDATE prices SET price1='".$price1."', price2='".$price2."', date='".$date."' WHERE id='".$id."' ");
Would I have to declare each value or just the ones I need updated?
You would declare only the field values that you want to update.
If this is not working for you, add a little debugging.
$sql = "UPDATE prices SET price1='$price1', price2='$price2', date='$date' WHERE id='$id'"; mysql_query($sql) or die($sql . "<br />" . mysql_error());
-
How do I make a reg expression for email validation? This is what I have:
/(\da-zA-Z)+@(\da-zA-Z)+\.(a-ZA-Z)+/
So it says, check one or more of digits, alphabets, followed by @, followed by one or more digits,alphabets, followed by '.', followed by one or more alphabets, but it's not working. I'm using a forms plugin in WordPress, and we have to enter our own reg expressions.
Any help for my approach is appreciated.
That is not what that regex says at all. You do not have your characters grouped in character classes. [a-zA-Z\d]
The regex that you have is not doing what you think it is, and no valid email will pass that.
-
yeah i think i will just remove the switch and use ternaries.
Let us know when this has been solved.
-
looks like you are trying to get a property from an array. where is $rsOptions[$j] coming from? Post the relevant code.
-
I think it would be best if you glanced at the switch statement syntax:
-
\d = digits [0-9]
[a-zA-Z] = letters (case insensitive)
[\s\t] = white space (matches a space and tab respectfully)
[^\s\t] = non-white space (matches anything other than the above white space characters)
what does this have to do with your original question?
-
... but that involves reading ...
but you referred the OP to articles, which involve more reading. Reading is an important factor in learning.
Yes this is caused by output being sent to the browser before setcookie() is being called. If there is no "seen" output being sent, the text editor you are using could be using a BOM (Byte Order Mark) for encoding.
-
On top of everything that has been said, use the code that I have provided in my last reply to verify the data in the SQL statement.
-
well, without the string ending anchor. A string like ",hey whats up" would match. If you want the alphanumeric character preceded by the comma to be the only match, then yes you need the ending anchor.
-
then this condition:
if(mysql_num_rows(mysql_query($verify)) != 0) { echo '<p class="fail">This email or username is already taken!</p>'; }
is returning FALSE, for some reason. The values are not comparing correctly to the values in the databse. Echo your SQL statement and verify the values.
if(mysql_num_rows(mysql_query($verify)) != 0) { echo '<p class="fail">This email or username is already taken!</p>'; } else { echo $verify; exit; //rest of code will not get executed }
-
But in some ebooks and also in some video tutorials i have read and watched, they did the same...
then you should toss them out.
-
because $verify is an SQL statement, a mysql_query resource needs to be passed to mysql_num_rows. e.g:
$verify = "SELECT * FROM login WHERE emailaddress = '$email' AND username = '$uname'"; if(mysql_num_rows(mysql_query($verify)) != 0)
-
this line:
if (mysql_num_rows(mysql_query("SELECT * FROM login WHERE emailaddress = '$email' username = '$uname'"))) {
should read:
if (mysql_num_rows(mysql_query("SELECT * FROM login WHERE emailaddress = '$email' AND username = '$uname'"))) {
you forgot the AND in the SQL statement.
-
<input type="text" name"test" id="test">
needs to read:
<input type="text" name="test" id="test">
instead of name"test" it needs to be name="test"
-
1. escape all user data before using in an SQL statement using mysql_real_escape_string (assuming your db server is MySQL). This will prevent SQL injection and XSS. however it is preferred to use PDO with prepared statements.
2. Do not use $_SERVER['PHP_SELF'] as a forms action, this will leave your forms open to XSS.
3. Make sure files and directories have the proper permissions so user cannot view and/or tamper with them.
There is a list of things that you can do for added security, I'm sure other users will list more. I will leave you with some reading from php.net on the security subject: http://php.net/manual/en/security.php
-
This is probably what you want:
<?php $string = '<b>Age:</b> 16'; if (preg_match('~<b>Age:</b> (\\d+)~', $string, $match)) { echo ((int)$match[1] < 18) ? 'minor' : 'adult'; } ?>
no.
If you are not sure of the age data and you need a tight regex you can use this.
$string = '<b>Age:</b> 16'; if (preg_match('~^<b>Age:</b> ([1-9][0-9]?|10[0-5])$~', $string, $match)) { //max age 105 echo ((int)$match[1] < 18) ? 'minor' : 'adult'; }
else, if you are sure of the data, you can use this:
$string = '<b>Age:</b> 16'; if (preg_match('~^<b>Age:</b> (\d{1,3})$~', $string, $match)) { echo ((int)$match[1] < 18) ? 'minor' : 'adult'; }
or even:
$pattern = '^<b>Age:</b> (\d+)$';
curious, where are you getting the contents of $line?
-
Hey AyKay47 what do you mean by debuging it.
do you mean by using this
ini_set("display_errors", "1");error_reporting(-1);
I just used this just now for the first time. so not sure what all it really displays, but im assuming it displays any errors and even if you start a variable out with _
how does everyone handle this. Should i just keep this on every page so its always active? Is that what most people do?
yes, follow what PFM said. In this case, if the OP had the error settings correct, he should have received an "undefined variable" error and an invalid handle error.
-
Every language has a different flavor of regex. Things that are valid in one might be invalid in another.
For your reading: http://www.regular-expressions.info/refflavors.html
-
-
in the fread() call, you have the handle set to $_fh1, when it should be $fh1.
You should always debug your code, that way little things like this are much easier to spot.
-
so, what exactly is your issue? Are the errors not being displayed correctly when they should be?
Date not getting deleted
in PHP Coding Help
Posted
debugging your query will show an error upon failure of the query.
If you did not receive any errors using the code I have posted, the problem is not with your query.