+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: script help

  1. #1
    CascadesAdmin is offline x10Hosting Member CascadesAdmin is an unknown quantity at this point
    Join Date
    Jun 2007
    Posts
    87

    script help

    I need help with this code:

    Using WHOLE new code, still need help

    PHP Code:
    <?
    //Database Information

    $dbhost "localhost";
    $dbname "cascades_sope1";
    $dbuser "cascades_sope1";
    $dbpass "hiimbob";

    //Connect to database

    mysql_connect $dbhost$dbuser$dbpass)or die("Could not connect: 

    "
    .mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    //end connecting to db


    //Storing Names
    //Secure (md5)

    $name $_POST['name'];
    $email $_POST['email'];    
    $username $_POST['username'];
    $password md5($_POST['password']);
    $emailpass = ($_POST['password']);
    //end secure
    //end storing names

    //checking if username already exists

    $checkuser mysql_query("SELECT username FROM users WHERE 

    username='
    $username'"); 

    $username_exist mysql_num_rows($checkuser);

    if (
    $username_exist 0){
       echo() 
    "I'm sorry but the username you entered has already been taken. 

     Please pick another one."
    ;
        unset(
    $username);
        include 
    'register.html';
        exit();
    }
    //end check

    //registrartion complete

    $query "INSERT INTO users (name, email, username, password)
    VALUES('
    $name', '$email', '$username', '$password')";
    mysql_query($query) or die(mysql_error());
    mysql_close());

    echo() 
    "You have successfully Registered";

    $yoursite = &#8216;fanclub.cascades.exofire.net/’;
    $webmaster = &#8216;Cascades Admin’;
    $youremail = &#8216;noreply@cascades.exofire.net’;

    $subject "You have successfully registered at $yoursite...";
    $message "Dear $name, you are now registered at our web site.  
             
                     PLEASE DO NOT REPLY TO THIS MESSAGE   

        To login, simply go to our web page and enter in the following 

    details in the login form:
        Username: 
    $username
        Password: 
    $emailpass
        
        Please print this information out and store it for future 

    reference.
        
        Thanks,
        
    $webmaster";
        
    mail($email$subject$message"From: $yoursite 

    <
    $youremail>\nX-Mailer:PHP/" phpversion());
        
    echo() 
    "Your information has been mailed to your email address.";


    ?>
    get this error message when I try to register to test

    Parse error: syntax error, unexpected ')' in /home/cascades/public_html/fanclub/register.php on line 34
    Last edited by CascadesAdmin; 07-10-2007 at 12:58 PM.

  2. #2
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: script help

    try this:
    PHP Code:
    <?php 
    $database
    [dbserver]="localhost"
    $database[dbuser]="cascades_sope1"
    $database[dbname]="cascades_sope1"
    $database[dbpass]="Removed For Obvious Reasons"
    $table ="users"
     
    $connect mysql_connect($database[dbserver], $database[dbuser], $database[dbpass]); 
     
    $selectmysql_select_db($database[dbname]); 
    ?>
    or this:
    PHP Code:
    <?php 
    $database
    ['dbserver']="localhost"
    $database['dbuser']="cascades_sope1"
    $database['dbname']="cascades_sope1"
    $database['dbpass']="Removed For Obvious Reasons"
    $table ="users"
     
    $connect mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass']); 
     
    $selectmysql_select_db($database['dbname']); 
    ?>
    Last edited by Chris Z; 07-09-2007 at 03:22 PM.
    -Chris Z
    Retired Account Manager


  3. #3
    Kansy's Avatar
    Kansy is offline Community Advocate Kansy is an unknown quantity at this point
    Join Date
    Oct 2006
    Location
    Cork Cirty, Ireland
    Posts
    2,621

    Re: script help

    mmm I think the first error is because an error with the DB login and user names.. try to delete your DB if its empty if not do a backup and create it another time... and chek again and if you need in the new DB upload all the tabls you have in the old

    I can't answer to the second error... Im sorry I have no Idea
    Si consideras que esto ha sido de ayuda, por favor no dudes en darme reputación usando el que encontrarás abajo a la izquierda del tema.

  4. #4
    Zenax's Avatar
    Zenax is offline Lord Of The Keys Zenax is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    The Brilliant United Kingdom
    Posts
    1,339

    Re: script help

    Chris Z is right on the connection script. You should leave the db server at local host:

    PHP Code:

    <?php 
    $database
    ['dbserver'] = 'localhost'
    $database['dbuser'] = 'cascades_sope1'
    $database['dbname'] = 'cascades_sope1'
    $database['dbpass'] = 'Removed For Obvious Reasons'
    $table 'users'
     
    $connect mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass']); 
     
    $selectmysql_select_db($database['dbname']); 
    ?>
    As for your login script, I use the following:

    PHP Code:

    <?php
    session_start
    ();

    // Require once the DB script
       
    require_once ($_SERVER['DOCUMENT_ROOT']. '/config.php');

       if (
    $_POST['loginSubmit']) {
          
    // You *always!* need to validate user-supplied data when using it in MySQL queries!!
          // This isn't 100% secure, but it's definitely better than having nothing and being vulnerable to SQL injection.
          
    if(get_magic_quotes_gpc()) {
             if(
    ini_get('magic_quotes_sybase')) {
                 
    $username str_replace("''""'"$_POST['username']);
                 
    $password str_replace("''""'"$_POST['password']);
             } else {
                 
    $username stripslashes($_POST['username']);
                 
    $password stripslashes($_POST['password']);
             }
          } else {
              
    $username $_POST['username'];
              
    $password $_POST['password'];
          }
          
    $username mysql_real_escape_string($username);
          
    $password mysql_real_escape_string($password);
          
          
    $check mysql_query("SELECT * FROM `users` WHERE `users` = '$username' and `password` = '$password' LIMIT 1");
          
          
    // Counting the table row
          // If the result is matched then $username, $password must be row 1
          
    $count = @mysql_num_rows($check);
          
          
    // Logged in!
          
    if ($count == (int) 1) {
             
    $_SESSION['site_username'] = $username;
             
    $_SESSION['site_password'] = $password;
             
             echo 
    '<link rel="stylesheet" href="style.css" type="text/css" />
    <div align="center">Welcome '
    $_SESSION['site_username'] .'. You are now logged in!<br /><a href="members">Click Here to Continue</a></div>';

             
    $_GET['do'] = 'manualUnset';
             
    // Do whatever ?
          
    }
          else {
             echo 
    'Error: Wrong username or password specified. <br />';
          }
       }

       
    // If $_GET['do'] is set to 'manualUnset', do not show login form, user already logged in.
       
    switch ($_GET['do']) {
          case 
    'manualUnset':
             break;
          default:
    ?>
    <link rel="stylesheet" href="style.css" type="text/css" />
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <table width="90%" border="0" cellspacing="0" cellpadding="5">
         <tr>
          <td>Username:</td>
          <td>Password:</td>
         </tr>
         <tr>
          <td><input type="text" name="username" /></td>
          <td><input type="password" name="password" /> &nbsp; <input name="loginSubmit" type="submit" value="Login" class="button" /></td>
         </tr>
        </table>
        </form>
    <?php
          
    break;
       }
    ?>
    If you have any more problems please let us know. Obviously the script I use is tailored to my needs, and if you want to use it you are more than welcome. All you would have to do is change around the names used in the script.

    Regards,
    Zenax
    Last edited by Zenax; 07-10-2007 at 05:18 AM.
    Regards,
    Zenax

  5. #5
    CascadesAdmin is offline x10Hosting Member CascadesAdmin is an unknown quantity at this point
    Join Date
    Jun 2007
    Posts
    87

    Re: script help

    whole new script, whole new problem...

  6. #6
    Cubeform is offline x10 Lieutenant Cubeform is an unknown quantity at this point
    Join Date
    Aug 2006
    Location
    127.0.0.1
    Posts
    339

    Re: script help

    PHP error messages are always so unhelpful.

    Try this: If line 34 is the line with
    PHP Code:
       echo() "I'm sorry but the username you entered has already been taken. 
    try getting rid of the parentheses; you don't need them anyway. Do the same every time you use echo in your script.
    Last edited by Cubeform; 07-10-2007 at 01:54 PM.
    CUBEFORM
    XHTML | CSS | PHP | JavaScript
    THIS WEEK


  7. #7
    CascadesAdmin is offline x10Hosting Member CascadesAdmin is an unknown quantity at this point
    Join Date
    Jun 2007
    Posts
    87

    Re: script help

    no because the parentheses are needed in php4. If you search on google for echo php syntax, it will tell you that the correct way is echo()

  8. #8
    t2t2t's Avatar
    t2t2t is offline x10 Elder t2t2t is an unknown quantity at this point
    Join Date
    Sep 2006
    Location
    Europe, Estonia
    Posts
    690

    Re: script help

    http://ee2.php.net/manual/en/function.echo.php
    echo() is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo() (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo(), the parameters must not be enclosed within parentheses.
    Believe in the manual! + you have totally wrong syntax! (The text has to be ("here") not () "here"
    Also, for line breaks, add <br />
    This post has been marked spam 52 times.


  9. #9
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: script help

    well if you need that, then it's supposed to be:
    PHP Code:
    echo('I\'m sorry but the username you entered has already been taken'); 
    Last edited by Chris Z; 07-10-2007 at 03:21 PM.
    -Chris Z
    Retired Account Manager


  10. #10
    Zenax's Avatar
    Zenax is offline Lord Of The Keys Zenax is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    The Brilliant United Kingdom
    Posts
    1,339

    Re: script help

    I have always used:

    PHP Code:
    echo 'I\'m sorry but the username you entered has already been taken!'
    I never use parenthesis. I used too, but my scripts work without them, so I do not consider it a fundamental thing to include!
    Regards,
    Zenax

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Script de status de los servidores
    By Reclutador in forum General
    Replies: 8
    Last Post: 12-21-2006, 09:27 AM
  2. [OFF] Script Instillations (Now Accepting)
    By kryptonyte in forum The Marketplace
    Replies: 0
    Last Post: 08-02-2006, 02:15 AM
  3. Server UP time Script
    By dharmil in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 04-03-2006, 04:39 PM
  4. Just a question about my script
    By rubens in forum Free Hosting
    Replies: 11
    Last Post: 02-28-2006, 01:41 PM
  5. CGI - script, Advertisement _HELP.
    By kaliforna in forum Free Hosting
    Replies: 12
    Last Post: 06-02-2005, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers