-4

Code looks fine, but it throws up an 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 is line 7, but even if i delete it, the error is same, so there is some error in line 8 also.

5 Answers5

2

I think you are using the wrong “ instead of " (notice they are 'italic')

please 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");
?>

edit:

Confirmed, this throws a invalid user/pass on my system :)

Matthijs
  • 1,112
  • 2
  • 12
  • 28
1

Use double or single quotes ( " / ' ) instead of a weird ” symbol

<?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");
Vladimir Hraban
  • 3,543
  • 4
  • 26
  • 46
1

Your double quotes look 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 I use mysql_* functions in PHP?

Community
  • 1
  • 1
Simone
  • 20,302
  • 14
  • 79
  • 103
1
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$type = $_POST['type'];
$data = $_POST['data'];

mysqli_connect("localhost", "user_name", "pass") or die("Could not connect: " . mysqli_error());
mysqli_select_db("db_name");
?>

Just to make sure: You know that you are connecting with username 'user_name' and password 'pass' to the database 'db_name'? Fixed strange quotes.

de_nuit
  • 650
  • 7
  • 13
-1

Replace :-

mysql_connect(“localhost”, “user_name”, “pass”) or
die(“Could not connect: ” . mysql_error());
mysql_select_db(“db_name”);

with

mysql_connect("localhost", "user_name", "pass") or
die("Could not connect: " . mysql_error());
mysql_select_db("db_name");
Vivek Sadh
  • 4,230
  • 3
  • 32
  • 49