NameSilo

Php/mysql help needed

SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
SpaceshipSpaceship
Watch

dx3k

Established Member
Impact
2
hey

can you tell me what is wrong with this script please i keep getting "unexpected ) on line 18"


PHP:
<?
include('sqlinfo.php');
$connect = mysql_connect($host, $account, $password);
$db = mysql_select_db("dx3k_logger)";       <<<< this is line 18
$query = "INSERT INTO ip VALUES (''$ip");

?>


thanks

dx3k
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
$db = mysql_select_db("dx3k_logger)";


should be

$db = mysql_select_db("dx3k_logger");
 
0
Close
still dont want to work

this is what i have now



PHP:
<?
$ip = $REMOTE_ADDR;
echo "$ip"; 
?>
<?
include('sqlinfo.php');
$connect = mysql_connect($host, $account, $password);
$db = mysql_select_db("dx3k_logger");   <<< line 18
$query = "INSERT INTO 'ip' VALUES (''$ip");

?>
 
0
Close
$query = "INSERT INTO 'ip' VALUES (''$ip");

that is wrong as well, you opened the quotes outside of the bracket but closed them in the bracket also wht do you have ''$ip

try :-

$query = "INSERT INTO 'ip' VALUES ('".$ip."')";
 
0
Close
now it is on about a T_STRING erro on line 18 ( i h8 this line lol) what is a t_string?




<?
include('sqlinfo.php');
$db = mysql_connect("$host", "$account");
mysql_select_db("dx3k_logger",$db);
$query = INSERT INTO `data` ( `ip` , `browser` )
VALUES (
'$ip'
);

?>



thanks

dx3k
 
0
Close
<?
include('sqlinfo.php');
$db = mysql_connect($host,$account);
mysql_select_db("dx3k_logger",$db);
$query = "INSERT INTO `data` ( `ip` , `browser` ) VALUES ('$ip')";
?>

That should work. Just note that you have two fields defined in the fields list and only one value, in case you intend to run the query.

I must really recommend you to read a few PHP beginner tutorials.
 
0
Close
i am already , most of the script i copyd from the book
 
0
Close
dx3k said:
now it is on about a T_STRING erro on line 18 ( i h8 this line lol) what is a t_string?




<?
include('sqlinfo.php');
$db = mysql_connect("$host", "$account");
mysql_select_db("dx3k_logger",$db);
$query = INSERT INTO `data` ( `ip` , `browser` )
VALUES (
'$ip'
);

?>



thanks

dx3k
Can you print out the line 18 here?
Thanks
 
0
Close
One of the following ought to be line 18 as it aint enclosed in quotes:
$query = INSERT INTO `data` ( `ip` , `browser` )
VALUES (
'$ip'
);
 
0
Close
you will need to enclose them in quotes, also why are you only assigning ip when your query should be inserting 2 lots of data (ip and browser)
 
0
Close
yer i got it to work now 100% my fault... i hadnt added myself as a user to the database :red: :red: i am an idiot :hehe:
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back