...

View Full Version : Resolved Need More Help -- MySQL connect



zackwiny
08-10-2008, 10:09 PM
Here is my code:

<?php

$server = "localhost"; // Database Server URL
$username = "user"; // Database Username
$password = "pass"; // Database Password
$database = "my_db"; // Database Name

$licenceid = $_REQUEST['session']; // Licence
$siteurl = "."; // Website URL

$myserver = mysql_connect($server,$username,$password);
mysql_select_db($database,$myserver);
$result = mysql_query("SELECT * FROM 'licences' WHERE licenceid = '" . $licenceid . "' LIMIT 1",$myserver);
$row = mysql_fetch_array($result);
if (!$myserver) {
die('<h1>Invalid Session</h1>');
}
if ($row['caninstall'] = 1) {
die('Invalid Session');
}
echo mysql_error($myserver);
$sitetitle = $row['title1'];
$sitetitle2 = $row['title2'];

echo $licenceid;
?>

And here is the error i'm getting
Parse error: syntax error, unexpected T_STRING in /home/*****/******/config.php on line 15

I've tried alot of this with it and i can't figure out why i'm getting it,

Line 15 is: if (!$myserver) {

If someone could sort this out for me that would be great :)

derzok
08-10-2008, 11:02 PM
The code works fine for me - are you sure you're running the most recent version of the code? Sometimes I forget to hit save or upload when I'm testing things - I'll spend hours trying to find a bug only to realize that I'm testing the wrong code.

zackwiny
08-10-2008, 11:09 PM
I'm sure about that part,
but i'll try making a new file and putting it in

[edit]
Well sry for this useless post,
it must have been some hidden character or something,
i did have to delete the $row = ... line and use $result['title1']; instead

Nightfire
08-10-2008, 11:09 PM
Looks ok to me, but this

if ($row['caninstall'] = 1) {


Should be
if ($row['caninstall'] == 1) {

zackwiny
08-10-2008, 11:18 PM
That would give an error,
so thanks for mentioning that...
i wouldn't have noticed :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum