Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    4
    Thanked 1 Time in 1 Post

    Need More Help -- MySQL connect

    Here is my code:
    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
    Last edited by zackwiny; 08-12-2008 at 05:25 PM. Reason: Resolved

  • #2
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    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.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • Users who have thanked derzok for this post:

    zackwiny (08-10-2008)

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    4
    Thanked 1 Time in 1 Post
    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
    Last edited by zackwiny; 08-10-2008 at 11:14 PM.

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Looks ok to me, but this

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


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

  • Users who have thanked Nightfire for this post:

    zackwiny (08-10-2008)

  • #5
    New Coder
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    4
    Thanked 1 Time in 1 Post
    That would give an error,
    so thanks for mentioning that...
    i wouldn't have noticed


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •