1. #1

    Help with computer coding!

    I cant find whats wrong in my text.. anyone want to help me find it..?

    <?php
    $host="localhost";
    $user="root";
    $pass="";



    $conn = mysql_connect( $host, $user, $pass );
    if (! $conn) {
    print ("Anslutningen misslyckades");
    exit;
    }


    mysql_select_db("bilar");


    $query = mysql_query("SELECT * FROM bilar");


    print ("<table border=\"1\">\n");


    while($t = mysql_fetch_row($query))
    {

    echo "<tr>";
    echo "<td>$t[0]</td><td>$t[1]</td><td>$t[2]</td>";
    echo "<td>$t[3]</td><td>$t[4]</td>";
    echo "</tr>\n";
    }


    print ("</table>");


    mysql_close( $conn );
    ?>



    <?php
    $host="localhost";
    $user="root";
    $pass="";
    ?>



    <form action="<?echo $_SERVER['PHP_SELF']?>" method="POST">
    Registreringsnummer:<br>
    <input type="text" name="reg"><p>

    Bilmärke:<br>
    <input type="text" name="marke"><p>

    Modell:<br>
    <input type="text" name="modell"><p>

    Årsmodell:<br>
    <input type="text" name="arsmodell"><p>

    Pris:<br>
    <input type="text" name="pris"><p>

    <input type="submit">
    </form>
    <?

    $reg = $_POST['reg'];
    $marke = $_POST['marke'];
    $modell = $_POST['modell'];
    $arsmodell = $_POST['arsmodell'];
    $pris = $_POST['pris'];



    $conn = mysql_connect( $host, $user, $pass );
    if (! $conn) {
    print ("Anslutningen misslyckades");
    exit;
    }


    mysql_select_db("user");


    mysql_query("INSERT INTO
    bilar (reg,marke,modell,arsmodell,pris)
    VALUES
    ('$reg','$marke','$modell','$arsmodell','$pris')");
    <?php
    $host="localhost";
    $user="root";
    $pass="";


    $conn = mysql_connect( $host, $user, $pass );
    if (! "conn") {
    print ("Anslutningen misslyckades");
    exit;
    }


    mysql_select_db("bilar");


    if (isset($_POST['reg'])) {
    $reg = $_POST['reg'];
    $query = mysql_query("DELETE FROM bilar WHERE reg='$reg'");
    }


    $query = mysql_query("SELECT * FROM bilar");


    print ("<table border=\"1\">\n");

    while($t = mysql_fetch_row($query))

    {

    echo "<tr>";
    echo "<td>$t[0]</td><td>$t[1]</td><td>$t[2]</td>";
    echo "<td>$t[3]</td><td>$t[4]</td>";
    echo "</tr>\n";
    }



    print ("</table>");

    mysql_close( $conn );


    ?>

    <form action="<?echo $_SERVER['PHP_SELF'];?>" method="POST">
    ange registreringsnummer att ta bort:<br>
    <input type="text" name="reg">
    <input type="submit">
    </form>

  2. #2
    You might want to be a little more specific, what language is that and what is the issue you're having with it?
    System Specs -
    CPU - i5 2500k @ 5ghz | CPU Cooler - RASA RX240 | Motherboard - Asus Maximus IV Gene-Z/Gen3| GPU - Nvidia GTX 590|
    SSD - Crucial M4 128GB | RAM - 8GB Corsair Vengeance | PSU - Corsair TX850M | Case - CoolerMaster HAF 922
    | Monitor - Crossover 27Q (2560x1440) | Sidewinder X4 Keyboard |


  3. #3
    Quote Originally Posted by Nab View Post
    You might want to be a little more specific, what language is that and what is the issue you're having with it?
    it´s php html code and it´s swedish! there is something in the text that isn´t right.. cuz it wont work!

  4. #4
    Titan
    Join Date
    Feb 2008
    Location
    Rotherham, England/UK
    Posts
    13,176
    First; What are you trying to do? If we don't know what you want to achieve, how on earth are we supposed to help you?
    Second; Tell us what errors you're given, or what you expect to happen and what actually happens.
    Third; Cut out all the excess blank lines (i.e. leave just one blank line between separate sections) and put it between [code][/code] tags.

    Until you give us that, it's unlikely anyone will be able to help you.
    [...]

Posting Permissions

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