Jump to content

RedNeckRabbit93

New Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by RedNeckRabbit93

  1. @menator01 Your suggestions helped me find the exact errors I was having trouble with. I appreciate the help. I guess once you spend hours looking at code that you tend to miss things, especially when something should work right and it doesn't. Now the only error I get is 

    Quote

    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in 

    @dodgeitorelse3 I have no clue how I missed that. I'm glad one of us had a sharp eye. Thank you.

     

    @Strider64 I have not taken the time to familiarize myself with PDO though I have heard of it. I never bothered to learn to use it, relying instead on older methods that I was more familiar with. I guess it is time to start evolving with the times and getting myself familiar with newer methods. I will research PDO and see if I can start using it instead. Thank you for the suggestion! 

  2. I have spent hours setting this code up along with the other parts of my site only to have a frustrating error keep populating. I have debugged all other errors but this one eludes me. Any chance ya'll could take a look and help me out? I appreciate it. Here is the code:

     

    <?php 
    
    /* I have intentionally removed these details for my own security */
    
    $host="";
    $user="";
    $password="";
    $db="";
    
    mysql_connect($host,$user,$password);
    mysql_select_db($db);
    
    if(isset($_POST['username'])){
    	$uname=$_POST['username'];
    	$password=$_POST['password'];
    	
    }
    	$sql="select * from auth where user='.$uname'AND Pass='.$password.' limit 1;
    	
    	$result=mysql_query($sql);
    	
    /*This if statement is the section that states I have an unexpected $end syntax error */
    	if(mysql_num_rows($result)==1){
    	header('Location: pay.php');
    	exit();
    	
    	else{
    		echo 'Username or Password is incorrect! Please try again.';
    		exit();
    	}
    }
    
    ?>

     

  3. 21 hours ago, Barand said:

    Your first one is missing a } before the else. Syntax is

    if (condition) {
        do something
    }
    else {
        do something else
    }

    It looks like $em  is not valid. Have you tried  var_dump($em) to check what's in there?

     

    PS You could just...

    if ( ($em = filter_var($em, FILTER_VALIDATE_EMAIL)) === false ) {
       echo "Invalid format"; 
    }

     

    Yeah, it comes out as bool false. Which means I've failed to inform PHP what I'm using $em for

  4. @Barand

    That fixed all the issues except for one. 

    if (filter_var($em, FILTER_VALIDATE_EMAIL)) {
      $em = filter_var($em, FILTER_VALIDATE_EMAIL);
      
      else {
        echo "Invalid Format";
      }
    
    }
    
    // This code gives me this error: Parse error: syntax error, unexpected 'else' (T_ELSE) in /*****/**/******/htdocs/site/register.php on line 60
    
    If i do it this way:
    
    if (filter_var($em, FILTER_VALIDATE_EMAIL)) {
      $em = filter_var($em, FILTER_VALIDATE_EMAIL);
      }
      else {
        echo "Invalid Format";
      }
    
    
    //It fixes the rror but the page is constantly returning echo "Invalid Format"; regardless of what is inputted into my form. 

     

  5. On 8/5/2021 at 10:50 AM, Barand said:

    Make sure you have defined the function insert(). It's not a PHP function.

    (Or did you mean isset() ?)

    Why did i not notice this? I am not completely new to PHP. Why in the world did I miss this function? I know better. Grrrrrr! I guess my frustration blinded me. I will fix it now. You are right, insert is not a PHP function. 

     

    @Barand

    You were correct. This fixed my entire issue. If i had just been paying attention I wouldn't be feeling like an idiot right now! Thank you Dear Sir!

  6. @Barand

     

    I went ahead and for the hell of it, added the corrections to the mistakes you noticed. However now i am getting this error.

    Fatal error: Uncaught Error: Call to undefined function insert() in register.php:18 Stack trace: #0 {main} thrown in register.php on line 18. 

     

    Line 18 references this line here: 

    if(insert($_POST['register_button'])) {

      // To handle the registration form
    }

  7. 15 minutes ago, Barand said:

    I see two syntax errors

    if (insert($_POST['register_button'])) {

    The { has no corresponding } later in the code.

    When i put a } here the syntax error reads "Unexpected } on line blabla"

     

        if (filter_var($em, FILTER_VALIDATE_EMAIL)) {
          $em = filter_var($em, FILTER_VALIDATE_EMAIL)
                                                      ^  
        }
    
          

    missing ; at the end of the line(Thank you for the catch!) You're right!

     

  8. Hello,

    I am currently coding a site from scratch. I know i can use templates and everything else but i want the experience. The HTML I've had down for years but it seems PHP is getting a little elusive for me. I'm trying to create a registration form and when i test my site i keep getting parse errors and syntax errors... mainly regarding the use of {} and if/else. Any help would be appreciated. Most of the code is still incomplete, I have to go back and fill in some areas I've left blank for now, but i have commented using // Where the browser is kicking back my errors. 

     

    “Any sufficiently advanced technology is indistinguishable from magic” (Arthur C. Clark, 1962) 

     

    <?php
    $con = Mysqli_connect("'', '', ''");
    if (Mysqli_connect_errno()) {
      echo "Failed to connect to DB. Please check your connection info." . Mysqli_connect_errno;
      // Only if there is an error.
    }
    //Declaring Variable for Registration form
    $fname = "";
    $lname = "";
    $em = "";
    $emc = "";
    $pass = "";
    $passc = "";
    $date = "";
    $error_array = "";
    
    if (insert($_POST['register_button'])) {
      // To handle the registration form
    
      // First Name Values
      $fname = strip_tags($_POST['reg_fname']);
      $fname = str_replace(' ', '', $fname);
      $fname = ucfirst(strtolower($fname));
    
      // Last Name Values
      $lname = strip_tags($_POST['reg_lname']);
      $lname = str_replace(' ', '', $lname);
      $lname = ucfirst(strtolower($lname));
    
      // Registration Email Values
      $em  = strip_tags($_POST['reg_email']);
      $em = str_replace(' ', '', $em);
    
      // Confirm Registration Email Values
      $emc = strip_tags($_POST['reg_emailc']);
      $emc = str_replace(' ', '', $emc);
    
      // Registrsation Password Values
      $pass = strip_tags($_POST['reg_pass']);
    
      // Registration Password Confirmation Values
      $passc = strip_tags($_POST['reg_passc']);
    
      // Registration Date Values
      $date = date("m-d-Y");
      
    // Here is where the browser keeps kicking back parse errors
      if ($em == $emc) {
      }
      else {
        echo "Email and Confirmation Email must match";
    
      }
        if (filter_var($em, FILTER_VALIDATE_EMAIL)) {
          $em = filter_var($em, FILTER_VALIDATE_EMAIL)
        }
    
          else {
          echo "Invlaid Format";
        }
    
    
    
    
    ?>

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.