+ Reply to Thread
Results 1 to 2 of 2

Thread: help

  1. #1
    xsystemx is offline x10Hosting Member xsystemx is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    4

    help

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>FOFDB</title>
    <link href="default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <?php include("./div/logo.php"); ?>
    <?php 
    include("./div/menu.php"); ?>
    <div id="wrapper">
    <?php include("./div/col-one.php"); ?>
    <div id="col-two">
    <div class="boxed">
    <h2 class="title">SUBMIT</h2>
    <div class="content">
    <p>
    <?php 
    $A 
    $_POST['Artist']; 
    $B $_POST['Album']; 
    $C $_POST['Song'];
    $D $_POST['GuitarX'];
    $E $_POST['GuitarH'];
    $F $_POST['GuitarM'];
    $G $_POST['GuitarE'];
    $H $_POST['BassX'];
    $I $_POST['BassH'];
    $J $_POST['BassM'];
    $K $_POST['BassE'];
    $L $_POST['DrumsX'];
    $M $_POST['DrumsH'];
    $N $_POST['DrumsM'];
    $O $_POST['DrumsE'];
    $P $_POST['Download'];
    $sqlQuery1 "SELECT * FROM `ARTIST` WHERE `ARTIST` = '$A' LIMIT 0 , 1";
    $sqlQuery2 "SELECT * FROM `ALBUM` WHERE `ARTIST` = '$A' AND `ALBUM` = '$B' LIMIT 0 , 1";
    $sqlQuery3 "INSERT INTO `ARTIST` (`id` ,`ARTIST`) VALUES (NULL , '$A');";
    $sqlQuery4 "INSERT INTO `ALBUM` (`ID` ,`ARTIST` ,`ALBUM` ,`YEAR` ,`ART` ) VALUES (NULL , '$A', '$B', '', '');";
    $sqlQuery5 "INSERT INTO `SONG` (`ID` ,`ARTIST` ,`ALBUM` ,`SONG` ,`DISC` ,`TIME` ,`TRACK` ,`CAREER` ,`TIER` ,`DOWNLOAD` ,`GX` ,`GH` ,`GM` ,`GE` ,`BX` ,`BH` ,`BM` ,`BE` ,`DX` ,`DH` ,`DM` ,`DE` )VALUES (NULL , '$A', '$B', '$C', 'NULL', 'NULL', 'NULL', NULL , NULL , '$P', '$D', '$E', '$F', '$G', '$H', '$I', '$J', '$K', '$L', '$M', '$N', '$O');"
    mysql_connect("") or die(mysql_error());
    mysql_select_db("xsystemx_songs") or die(mysql_error());
    if $A == $sqlQuery1 then echo "VALID ARTIST" else $sqlQuery3 will run
    if $B == $sqlQuery2 then echo "VALID ALBUM" else $sqlQuery4 will run
    $sqlQuery5 runs no matter what
    What would i have to do to pull that off?
    PHP Code:
    ?>
    </p>
    </div>
    </div>
    </div>
    <?php include("./div/col-three.php"); ?>
    </div>
    <?php include("./div/footer.php"); ?>
    </body>
    </html>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: help

    Your subject line is terrible. You'll probably get more help in the future if you write better ones.

    Quote Originally Posted by xsystemx View Post
    PHP Code:
    <div id="wrapper">
    <?php include("./div/col-one.php"); ?>
    <div id="col-two">
    <div class="boxed">
    <h2 class="title">SUBMIT</h2>
    <div class="content">
    <p>
    <?php 
    $A 
    $_POST['Artist']; 
    $B $_POST['Album']; 
    $C $_POST['Song'];
    ...
    Yay! You've given your included scripts more descriptive names. You still need to do the same for your variables. You're also still not filtering the user input.

    Any time you find yourself repeatedly typing very similar lines in sequence, use a loop.

    Quote Originally Posted by xsystemx View Post
    PHP Code:
    mysql_connect("") or die(mysql_error());
    mysql_select_db("xsystemx_songs") or die(mysql_error()); 
    Rather than die()ing, use an if statement. die() will prevent the rest of your page (including footers) from being sent.
    Quote Originally Posted by xsystemx View Post
    if $A == $sqlQuery1 then echo "VALID ARTIST" else $sqlQuery3 will run
    if $B == $sqlQuery2 then echo "VALID ALBUM" else $sqlQuery4 will run
    $sqlQuery5 runs no matter what
    What would i have to do to pull that off?
    You're almost there. Rather than testing if $A is equal to anything returned by $sqlQuery1, test if the query returned no rows. If so, run $sqlQuery3. Do similar for $B/$sqlQuery2/$sqlQuery4. You might also want to give the queries more descriptive names, such as $lookForArtistQuery and $insertArtistQuery.

+ Reply to Thread

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