www.webdeveloper.com
Results 1 to 5 of 5

Thread: PHP scripts and MYSQL/PhpMyAdmin - Not connecting and no error message

  1. #1
    Join Date
    May 2014
    Posts
    30

    PHP scripts and MYSQL/PhpMyAdmin - Not connecting and no error message

    Hi there

    Was trying to run some basic php scripts yesterday to test uploading a file and I was finding that even though the tests I did that test connections worked it seems that when I ran the scripts nothing happened. I didn't even get an error message.

    Now I'm using phpmyadmin and it seemed that I everything was correct in the setup but still nothing is happening.

    This scripts are below.

    Is it possible that it could be a problem with the config.inc.php file? Oh I'm using XAMPP by the way.

    Thanks


    <form enctype="multipart/form-data" action="upload.php" method="POST">
    Name: <input type="text" name="name"><br>
    Genre: <input type="text" name = "genre"><br>
    Track: <input type="file" name = "track"><br>
    <input type="submit" value="Upload">
    </form>



    <?php

    // Connects to your Database
    mysql_connect("localhost", "root", "my_password") or die(mysql_error()) ;
    mysql_select_db("fxmas") or die(mysql_error()) ;

    //This is the directory where music will be saved
    // $target = "music/";
    //$target = $target . basename( $_FILES['track']['name']);

    //This gets all the other information from the form
    $name=$_POST['name'];
    $genre=$_POST['genre'];
    $file=$_FILES(['track']['tmp_name']);

    }
    ?>

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    802
    Did you forget something? Besides posting the code in the proper forum tags? You're not showing us any evidence of wrong-doing here.

  3. #3
    Join Date
    May 2014
    Posts
    30
    Ok here's my code in the correct format

    PHP Code:
    <!doctype html>

    <html lang="en">
    <head>
        <!--how browser interprets stuff-->
        <meta charset="utf-8" />
        <title>FXMAS</title>
        
        <link rel="stylesheet" href="main.css" />
        
    </head>
    <body>
        <div id=big_wrapper">
        
    <form enctype="multipart/form-data" action="upload.php" method="POST"> 
     Name: <input type="text" name="name"><br> 
     Genre: <input type="text" name = "genre"><br> 
     Track: <input type="file" name = "track"><br> 
     <input type="submit" value="Upload"> 
    </form>


        <header id="main_header">
        
            <h1></h1>
            <h4></h4>
        </header>
        <nav id="menu">
        <form method="get" action="/search" id="search">
      <input name="q" type="text" size="40" placeholder="Search..." />
    </form>
            <ul>
                <li><a href="music.html">Music</li>
                <li><a href="fx.html">FX</li>
                <li><a href="upload.html">Upload</li>
                <li><a href="forum.html">Forum</li>
                <li><a href="reports.html">Reports</li>
                <li><a href="about.html">About</li>
            </ul>
        </nav>
        <section>
            <article>
                <header>
                <hgroup> <!--when you have more than one header-->
                    <h1></h1>
                    <h2></h2>
                </hgroup>
                </header>
                <p></p>
                <footer>
                    <p>written by Jamie 2014</p>
                </footer>
            </article>
            
            <article>
                <header>
                <hgroup> <!--when you have more than one header-->
                    <h1></h1>
                    <h2></h2>
                </hgroup>
                </header>
                <p></p>
                <footer>
                    <p>written by Jcse7en 2014</p>
                </footer>
            </article>
        </section>
        
        <aside>
            <h4></h4>
            
        </aside>
        <footer>
            Copyright FXMAS 2014
        </footer>
        </div>
    </body>
    </html>

     <?php 
     
    // Connects to your Database 
    mysql_connect("localhost""root""Trinity77") or die(mysql_error()) ; 
    mysql_select_db("fxmas") or die(mysql_error()) ; 
     
     
    //This is the directory where music will be saved 
    // $target = "music/"; 
     //$target = $target . basename( $_FILES['track']['name']); 
     
     //This gets all the other information from the form 
    echo $name=$_POST['name']; 
    echo 
    $genre=$_POST['genre']; 
    echo 
    $file=$_FILES(['track']['tmp_name']); 
     

     
     } 
     
    ?>

  4. #4
    Join Date
    May 2014
    Posts
    30
    Well the reason I haven't shown any evidence of wrong doing is because I think I've done everything correct in terms of the code and setting up PHPMyadmin however it still fails to connect, that is why I have asked for help here.

    Thanks

  5. #5
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    802
    1 - turn on php error checking.
    PHP Code:
        error_reporting(E_ALL E_NOTICE);
        
    ini_set('display_errors''1'); 
    This will point out some of your errors.

    2 - you have a " problem at the very start of your body tag. That's a big problem. Did you even try to view the source of your web page in your browser? I doubt it would show much.

    3 - RTFM and learn how you are supposed to use the MySQL_connect and MySQL_select functions. Quick question - how do you use your 'connection' in your code when you don't capture a handle? (Of course your code (as presented) actually DOESN'T use your connection.)

    4 - You still haven't shown us ANYTHING that would indicate you have a problem here. Your code doesn't do anything as presented here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles