I use this following codes to make new users in website. it’s like sign up page. it’s working perfectly in localhost and data will insert to the database and the table but now in the server it won’t work.
$code = rand(11111,99999);
$link1 = mysql_connect("http://www.mysite.com","username","password");
mysql_select_db("username");
mysql_query("SET character_set_results= 'utf8' , character_set_client = 'utf8' , character_set_connection = 'utf8',
character_set_database ='utf8', character_set_server = 'utf8' ");
mysql_query("INSERT into user(name,family,email,gender,username,pass)
values('$_POST[name]','$_POST[family]','$_POST[email]','$_POST[gender]','$_POST[username]','$code')");
mysql_close($link1);
//connection user pass
$link2 = mysql_connect("http://www.mysite.com","username","password");
mysql_select_db("username");
mysql_query("INSERT into joinuser(username,pass,permission)values('$_POST[username]','$code','user')" );
mysql_close($link2);
It inserts the values in localhost but it won’t work in the server.
It’s php with mysql database.
Any help will be appreciated.
"http://www.mysite.com"is wrong. You cannot connect to MySQL using HTTP.In most cases, you will only ever need to use
localhostand allow the library to connect via a local socket rather than TCP/IP.If you are connected to a database server running on a different machine to the HTTP server, then you would use the hostname (and optionally the port). You wouldn’t specify a URL scheme of any kind.