-2

Please can I get help for this problem

Here's the code:

if( $_GET["sender"] == "Ajax" )

require_once "../db/connector.php";

else if ( $_GET["sender"] == "Ajax5" )

require_once "../db/connector.php";

else
require_once "db/connector.php";

//require_once "db/dbclass.php";

$mysql = new Datalink(localhost,root,'','whatsapp_dbase');


$id = $_GET['id'];  

Here's the Error Message

Notice: Use of undefined constant root - assumed 'root' in C:\wamp\www\whatsapp\db\mobilefx.php on line 9 Notice: Undefined index: id in C:\wamp\www\whatsapp\db\mobilefx.php on line 11 Notice: Use of undefined constant localhost - assumed 'localhost' in C:\wamp\www\whatsapp\db\mobilefx.php on line 9 Notice: Undefined index: sender in C:\wamp\www\whatsapp\db\mobilefx.php on line 2

1 Answers1

2

Many problems in this code :

Notice: Use of undefined constant root

Change :

$mysql = new Datalink(localhost,root,'','whatsapp_dbase');

To :

$mysql = new Datalink(localhost,'root','','whatsapp_dbase');

PHP is looking at root and thinks it's a constant because you didn't enclose it with quotes (or double quotes) to tell PHP it's a string.

Same goes for localhost :

Notice: Use of undefined constant localhost

Change :

$mysql = new Datalink(localhost,'root','','whatsapp_dbase');

To :

$mysql = new Datalink('localhost','root','','whatsapp_dbase');

Other errors come up because you didn't check whether or not $_GET variables existed before using them.

This is a duplicate though, so I won't go into details, learn more here.

Community
  • 1
  • 1
Steve Chamaillard
  • 2,289
  • 17
  • 32