Jump to content

Noxin

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by Noxin

  1.  

    $_user (an underscore at the beginning of a variable name is usually used to indicate the variable is private - like in class visibility)

     

    This will come up time and time again, so I might as well say it now - meaning you might as well spend a little time learning it now rather than later - when you have no choice.

    Best practices for database interactions are to use prepared statements. The code you presented in this regard is deprecated and slated for removal. This means it won't run on newer versions of PHP and it will look like you don't know what your doing if you present code in this manner expecting a paycheck someday. http://php.net/manual/en/mysqli.quickstart.prepared-statements.php

    <?php
    
    // don't let php hide any errors every how humbling it makes you feel 
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    
    if ( isset($_POST['submit']) )
    {
        if ( isset($_POST['password']) && isset($_POST['user']) )
        {
            $password = trim($_POST['password']);
            $user = trim($_POST['user']);
    
            $con = new mysqli($host, $user, $password, $dbname);
    
            if ($con->connect_errno)
            {
                die('Connection failed: ' . $con->connect_error);
            }
            // do your database stuff here
        }
    }
    

    So if what you say is right which I assume it is is the code you present me, the right way to write the document??

     

    Also May I have your permission to use it please!

  2. <?php
    if(isset($_POST['submit'])){
    $_user=$_POST['user'];
    }
    if(isset($_POST['submit'])){
    $password=$_POST['password'];
    }
     
    if ($user&&$password){
    $connect = mysql_connect("*******************************Secret Password Stuff****************************") or Die("Could not Connect");
    mysql_select_db("users") or Die ("Could not find DB");
    }
     
    else
    die ("Data Base Is dead we still have a Problem");
     
    ?>
     
     
     
     
    This is the error code:
     
     
     

    Notice: Undefined variable: user in C:\Users\RoSeAnN\Desktop\Web Designing\server\htdocs\connectionphp.php on line 9
    Data Base Is dead we still have a Problem
     
     
     
    And Html... if you need it
     
     
     
    <html>
    <form action='connectionphp.php' method='POST' accept-charset='UTF-8'>
    Username:<input type='text' name='user'>
    Password:<input type='password' name='password'>
    <input type='submit' value='Log in'>
    </form>
     
    </html>
     
     
     
    so what am I not doing wrong here and how can i make it work??? All help is much appreciated Thank you!
     
     
    ;D  
  3. Did you see Ch0cu3r reply? It should fix your code.

     

    The following should work (note the semi-colon after the second echo):

     

    Yes I did. It solved the problem eventually.

    How ever reading a piece of code that worked straight away was much more helpfull,

    Because of that help I have moved on today a lot and now understand PHP better.

     

    But thank you to everyone who posted it has all helped!! I'm sure I'm going to be back with some more noob stuff soon. :)

  4.  

    Good news is usually PHP provides more guidance regarding errors.

     

    Bad news is when you are just starting off, you will get a bunch of these.

     

    At first, try to keep your echo's small and don't mix single and double quotes.  I always "just because" put parenthesis around the stuff I want to echo.  Know that a semicolon is "mostly" end of command, and keep an eye out for them.   Use a dot (.) to join stuff.

    <?php
      $myname = 'Noxin';
      echo
     '<p>This is PHP</p>'.
     "<p>My name is $myname</p>".
     '<p>My name in another notation is still  '.$myname.'</p>';
     ?>

    PS.  See http://php.net/manual/en/language.types.string.php

     

    Also, I would probably use the following even though the curly brackets are not required:

      echo("<p>This is PHP</p><p>My name is {$myname}</p><p>My name in another notation is still  {$myname}</p>");

     

    Thanks for this line of code but what made this work???

     

    Its nice to know that php and mysql are working as they should on my system

     

    I think this Forum should make some newbie challenges that are easy to solve for you pro's, But challenging for beginners.

    The stuff on the web in just un-accurate and with no one there to help you figure the problems out its near impossible to get your head around.

     

    Thank you for this problem solve Im going to sit and compare the two codes now and try to understand where I went wrong. :)

  5. @Noxin the original code you posted in line 1 was fine the problem was with the word   and  on line 3. All you needed to was remove that word and this would of solved the error.

     

    and is a logical operator they should only be in control structures, ie when comparing values

     

    ok did just that still got a error on line 7 code stands at:

     

    <?php
     
      $myname = 'Noxin';
       echo '<p>This is PHP</p>';
      echo "<p>My name is $myname</p>"
      echo '<p>My name in another notation is still  '.$myname.'</p>';
    ?>
     
    ERROR is 
     
    Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in C:\Users\RoSeAnN\Desktop\Web Designing\server\htdocs\Practice.php on line 7
     
     
    Do I just delete the echo???
  6. LoL final reply to my own post tonight

     

    code is this

     

    <?php
     
      $myname = 'Noxin';
      echo
     '<p>This is PHP</p>';
     "<p>My name is $myname</p>"
     '<p>My name in another notation is still  '.$myname.'</p>';
    ?>

     

    new error

     

    Parse error: syntax error, unexpected ''<p>My name in another notatio' (T_CONSTANT_ENCAPSED_STRING) in C:\Users\RoSeAnN\Desktop\Web Designing\server\htdocs\Practice.php on line 7

  7. Boooo!

     

    ok so ive solved some of the issues but the new problem is dosent show everything I Wish it to show this is the new layout;

     

    <?php
      $myname = 'Noxin';
      echo
      '<p>This is PHP</p>';
     "<p>My name is $myname</p>";
     '<p>My name in another notation is still  '.$myname.'</p>';
    ?>

     

     

     

     

    and this is all that shows on the localhost page

     

    This is PHP

     

     

    how to get the rest of the code to come out?

  8. I was reading how to do some beginner stuff in PHP so this to you guys is easy right?

    Why dosent the code work properly? And or am I trying stuff that is to advanced for a total noob??

     

    this is the php code from the tutorial:

     

    <?php
      $myname = 'Noxin';
      and
      echo '<p>This is PHP</p>';
      echo "<p>My name is $myname</p>"
      echo '<p>My name in another notation is still  '.$myname.'</p>';
    ?>
     
    This is what appears on my localhost:
     
    Parse error: syntax error, unexpected 'and' (T_LOGICAL_AND) in C:\Users\RoSeAnN\Desktop\Web Designing\server\htdocs\Practice.php on line 3
     
  9. Id like to introduce myself as Noxin, I came into building sites earlier this year I've completed several sites as training so far.

    Each time learning and expanding my knowledge my latest site I have half completed easily, I think people in the industry would say I've completed the front end.

    But this time I'm adding login's registration and payment systems I think this is know as the back end of a site.

    I came to this site because I really need some help from people who really knows PHP.

    So I've been on google and youtube trying to pick up as much knowledge as I could to self teach myself, but the things people say to type in for example: I'd like to give a example but I'm not home yet. But a error will come back on my xammp server as a error on line 4 or something.

    So I don't know if php code changes for the different patches that comes out or something or if the stuff people have been saying to type is wrong.

    All I know is I'm using notepad++ and I have xammp with php 5.6.3

     

    Any help would be fantastic and sorry for the long intro.

     

    Noxin

×
×
  • 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.