PHP gives T_STRING error when connecting to MySQL -


code looks fine, throws error:

"parse error: syntax error, unexpected t_string in /home/u924861036/public_html/press.php on line 7"

<?php $ip = $_server['remote_addr']; $type = $_post['type']; $data = $_post['data'];  mysql_connect(“localhost”, “user_name”, “pass”) or die(“could not connect: ” . mysql_error()); mysql_select_db(“db_name”); 

the second last line line 7, if delete it, error same, there error in line 8 also.

your double quotes weird.

try this:

<?php $ip = $_server['remote_addr']; $type = $_post['type']; $data = $_post['data'];  mysql_connect("localhost", "user_name", "pass") or die("could not connect: " . mysql_error()); mysql_select_db("db_name"); 

and please use mysqli or pdo instead of mysql_* functions.

why shouldn't use mysql_* functions in php?


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -