Jump to content
MakeWebGames

Recommended Posts

Posted
As mysql's site no longer offers the tool, can you help me mtg?

If you're on MCCodes V2.0.5 (which judging by your posts on several mods you are), this can be done via the config file. In the config, there is a "driver" setting. Change that from 'mysql' to 'mysqli'.

~G7470

Posted
Yeah updated the driver. Now hopefully upgrading to php 7 works too :)

I haven't tested out php 7 with MCCodes, so I have no idea whether or not that will work. I would be surprised if it worked without any issues tbh.

~G7470

Posted

Here is one I found...And Kyle I KNOW....but is action now an issue?

 

switch ($_GET['action'])
{
case "add":
   add_contact();
   break;
case "remove":
   remove_contact();
   break;
default:
   contacts_list();
   break;
}

 

A non-critical error has occurred. Page execution will continue. Below are the details:

PHP Notice: Undefined index: action (8)

Line executed: /home/public_html/contactlist.php:39

 

And yes it's just a notice the page does display. But the notices are there for a reason. I feel fixing notices can help prevent more issues in the future.

Posted

Yes, but the undefined index is

 

switch ($_GET['action'])
{
case "add":
   add_contact();
   break;
case "remove":
   remove_contact();
   break;
default:
   contacts_list();
   break;
}  

 

and GET action has never been a variable that I'm aware of. So was just wondering if it was a php 7 thing.

Posted

well whatever it is. It's in contact list which is a standard mccode 2.0.5 file. So there are definitely going to be issues with the php 7.

 

Not to mention after how many attempts there is still no clear definition of how to get rid of these undefined. I've been able to understand most of what you guys have said. But for whatever reason undefined slips past me every time >.<

Posted

Well half of the time the issue was simply not including the $value in the SELECT from.

But I have seen so many ways of defining a variable/array it's ridiculous. What I do know is a variable is basically a constant. Representing an item or amount. While an array is several values.

That's all I have understood so far.

Posted (edited)

An array is a dictionary of keys/indexes and their values. It's basically a multi-dimensional variable.

This is pretty much exactly why you need to check your arrays before using them for example:

$data = array(
   'index1' => 10,
   'index2' => 5,
);
echo $data['index3']; // will result in an error 'undefined index index3 (6)'
$data['index3'] = 1;
echo $data['index3']; // will return 1

These errors can easily be avoided by using things such as isset() or array_key_exists() but these are different:

http://codepad.org/SDsWmLmq

Edited by KyleMassacre
Added code pad link
Posted

ok, so in this case

 

 switch ($_GET['action'])
{
case "add":
   add_contact();
   break;
case "remove":
   remove_contact();
   break;
default:
   contacts_list();
   break;
}   

 

the default is not defined. but the default does not have an action. Soooo?????

Posted

Can you start a new topic because this is going way off topic and I can't figure out for the life of me how to split this on my phone. And I am at work.

When I get a chance after work I will merge all of these into that new topic

Posted

*sigh* Please actually read the answers granted.

Add:

$_GET['action'] = array_key_exists('action', $_GET) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null;

if you want it to be done properly in this case, or

if(!isset($_GET['action'])) $_GET['action'] = '';

if not - above the

switch($_GET['action'])
Posted
*sigh* Please actually read the answers granted.

Add:

$_GET['action'] = array_key_exists('action', $_GET) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null;

if you want it to be done properly in this case, or

if(!isset($_GET['action'])) $_GET['action'] = '';

if not - above the

switch($_GET['action'])

A little overkill on it much haha. The switch statement will handle most of the security you provided by going to the default if it's not one of the cases defined right?

FYI....

I moved this to a new topic from here: http://makewebgames.io/forum/general-development-central/services/24426-free-mysql-to-mysqli-conversion

Posted

A little overkill on it much haha. The switch statement will handle most of the security you provided by going to the default if it's not one of the cases defined right?

FYI....

I moved this to a new topic from here: http://makewebgames.io/forum/general-development-central/services/24426-free-mysql-to-mysqli-conversion

Perhaps, but this also filters in for SilLYCaSe actions.

without strotlower()

file.php?action=SomEThing = default

with it

file.php?action=SomEThing = whatever "something" is.

Good for developers who make typos or catch the shift key too often (I have done both many times)

Posted

Aye, perhaps it be a little overkill, I just like to cover as many bases as possible.

For most, though:

if(!isset($_GET['action']))
   $_GET['action'] = null;

should be enough

(though I would recommend the use of array_key_exists() over isset() in these cases

Posted
Aye, perhaps it be a little overkill, I just like to cover as many bases as possible.

For most, though:

if(!isset($_GET['action']))
   $_GET['action'] = null;

should be enough

(though I would recommend the use of array_key_exists() over isset() in these cases

Correct which was why I posted the little snippet to show the main difference between the two

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...