$link isn't available to the scope of the function clean(). You'll need to pass the link into the function to use it.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
That function does nothing. Since it doesn't take a reference and it doesn't reassign the result, and the function call to mysqli_real_escape_string is invalid, it simply throws a warning and keeps going. Presumably you are later fetching from $_GET directly again which is why it looks like it is working.
Enable your error reporting
It will tell you that there is an error on calling mysqli_real_escape_string.
What you want to do is:
PHP Code:
function clean(MySQLi $link, $str) { $str = trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysqli_real_escape_string($link, $str); }
$fname = clean($link, $_GET['fname']);
Or convert to prepared statements which do not require the real_escape_string call.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Notice: Undefined variable: errflag in /home/countrymusic/countrymusic.org.uk/html/calendar/register-exec.php on line 86 Deprecated: Function eregi() is deprecated in /home/countrymusic/countrymusic.org.uk/html/calendar/register-exec.php on line 132 Notice: Undefined index: m in /home/countrymusic/countrymusic.org.uk/html/calendar/register-exec.php on line 140 Notice: Undefined variable: name in /home/countrymusic/countrymusic.org.uk/html/calendar/register-exec.php on line 174
I'm not worried about "Notice: Undefined index:" and "Undefined variable: name in ", but it seems to me that "Function eregi() is deprecated" needs looking at.
I will do some Googling and see what I can come up with.
Once again, THANK YOU for all your help.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
why are you not worried about that? it indicates a problem somewhere (no data availability check in this case) that may somewhen bite back at you.
Indeed. Error reporting should be turned on permanently so that nothing is being hidden. I don't know about anyone else but I don't feel happy with even mild warning messages - I have to solve everything before I'm happy with it.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
First of all can I explain that I didn't write this script.
I bought the script, called Broadfast. It is a mass email script and has a registration element to it.
The terms of the author is that the script can be used as many times as required, by me, and can be modified accordingly.
Quote:
the ereg* functions are now replaced by the preg* functions
Thank you for your advice.
However, I did google it and found the solution.
Quote:
I'm not worried about "Notice: Undefined index:" and "Undefined variable: name in "
The reason that I'm not worried about these is that the script is a double opt-in script.
'm' is generated by the script and emailed to the subscriber for confirmation. The second part of the double opt-in.
'name' was already in the script and I hadn't removed it. I have now removed that part of the script.
My error reporting now reads:
Code:
Notice: Undefined variable: errflag in /home/countrymusic/countrymusic.org.uk/html/calendar/register-exec.php on line 75 Notice: Undefined index: m in /home/countrymusic/countrymusic.org.uk/html/calendar/register-exec.php on line 129
'Notice: Undefined variable: errflag' is a mystery to me. This is the offending code:
It looks to me that $errflag is set to true, as in code above.
This part of the script certainly works.
It is designed to check for a duplicate email address and if one exists the email count is increased by 1. This is the code:
PHP Code:
//IF THE EMAIL ADDRESS IS A DUPLICATE
$query = "select emailcount from bf_users where email = '$email'";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_row($result);
if($row)
{
$emailcount = $row[0];
$emailcount++; // ADD ONE TO THE $emailcount
$result = mysqli_query($link, $query);
}
Can you please explain why it is throwing up an error ???
Thank you very much for your help and advise.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
Indeed. Error reporting should be turned on permanently so that nothing is being hidden.
Do you mean by this, even when the script is in use ???
Quote:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
I don't understand this.
I wonder if you would explain what you mean (in Noddy terms) so that I can understand it.
Thank you very much.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
'Notice: Undefined variable: errflag' is a mystery to me. This is the offending code [...]
if you return no results from the query, the condition that set $errflag is never executed and hence $errflag doesn’t exists. the easiest solution is to set $errflag to the default value (false, I guess) before that condition (either directly before the condition or at the beginning of the function) so that the default value is *changed* when the condition is met.
Quote:
Originally Posted by countrydj
Hi tangoforce...
Do you mean by this, even when the script is in use ???
if the script works without error, what is there to report? though sensibly any reports should be routed to the responsible developer (there are some config options in PHP for that purpose)
Quote:
Originally Posted by countrydj
I don't understand this.
I wonder if you would explain what you mean (in Noddy terms) so that I can understand it.
Internet explorer has a bug and does not always send the submit value. (important part underlined)
welcome to the world of cross-browser issues.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Last edited by Dormilich; 02-06-2013 at 12:14 PM..
I'm sorry, but I don't understand this statement, or the relevance to this thread.
Can you please explain for me.
Thank you.
I was referring to one of your original posts to where Fou-Lu was explaing to you the options and way to use escape inside your functions when it comes to MySQLi requirements.
Do you mean by this, even when the script is in use ???
I don't understand this.
I wonder if you would explain what you mean (in Noddy terms) so that I can understand it.
Thank you very much.
It's my signature (just like you'll see under this post). If you look at the bottom, there is a link that actually explains the IE bug. Click it and learn
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
Errors, including notices, should be fixed regardless of it you are concerned of the value or not. You can end up in trouble if you attempt to use them within say, comparisons, due to PHP's datatype weak nature (false = 0 = 0.0 = '0' = '' = null = array() = declared but not instantiated member properties). This can cause unwanted behaviour.
If something is not set, such as a checkbox (which is the only thing through $_POST that shouldn't be successful, aside from the possible IE bug of course), than you simply default the values to something so that reading doesn't cause any issues:
So long as its initialized to something, than you can treat it as if it does exist without throwing an error. Of course the default value should be that of what you can evaluate after, an empty string for a text entry (or even number if you anticipate numerical input), arrays for checkboxes, etc.
If I were you, I'd be more concerned of undefined offsets / variables than that of deprecated eregi. As mentioned, eregi is *slightly* different than PREG, but the conversion is little more than a find and replace click for most basic patterns.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php