Jump to content

zyra

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by zyra

  1. I've been trying to insert something into a table, but no matter what I do, it never works. I've been at it for hours. The whole script looks like this:

    $id = $_POST['id'];
    mysql_connect("localhost", "zyra_*****", "*******") or die(mysql_error());
    mysql_select_db("zyra_sciencefair") or die(mysql_error());
    mysql_query("CREATE TABLE $id (
    letter varchar(1) COLLATE latin1_general_cs NOT NULL,
    code varchar(2) COLLATE latin1_general_cs NOT NULL,
    UNIQUE KEY letter (letter,code)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs") or die (mysql_error());
    echo("Yes");
    $query = "SELECT * FROM Letters";
    $queryb = "SELECT Permutations FROM Permutations ORDER BY RAND()LIMIT 1";
    $queryc="INSERT INTO `zyra_sciencefair`.$id (letter, code) VALUES ('$entry','$entryb')";
    $x=1;
    while($x<95){
    $result = mysql_query($query) or die(mysql_error());
    $resultb = mysql_query($queryb) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());
    $rowb = mysql_fetch_array($resultb) or die(mysql_error());
    $entry = $row['letters'];
    $entryb = $rowb['Permutations'];
    mysql_query($queryc)or die(mysql_error());
    $x=$x+1;
    }
    ?>
    

     

    I have a feeling that $entry is empty, and somehow nothing got passed down to it. And everything works fine until you get to the whiole loop. Please help!

  2. So, I'm trying to make a code to create a table, and I'm really new to mySQL. So I used phpMyAdmin for the code, and it gave me:

    CREATE TABLE `$id` (
    `Character` varchar(1) COLLATE latin1_general_cs NOT NULL,
    `Code` varchar(2) COLLATE latin1_general_cs NOT NULL,
    UNIQUE KEY `Character` (`Character`,`Code`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
    

     

    But it didn't work right, so I tried fixing it and got:

     

    <?php
    mysql_connect("localhost", "zyra_*******", "*****") or die(mysql_error());
    mysql_query("CREATE TABLE $id (
    Letter varchar(1) COLLATE latin1_general_cs NOT NULL,
    Code varchar(2) COLLATE latin1_general_cs NOT NULL,
    UNIQUE KEY Character (Character,Code)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs") or die (mysql_error());
    ?>
    

     

    But then it started giving me a weird error.

    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( Character varchar(1) COLLATE latin1_general_cs NOT NULL, Code varchar(2) COLLAT' at line 1"

    And I have no idea what to do. Please help!

  3. I am trying to make a multiple choice quiz,but for some reson it wont work.

    <div align="center">
    <p>
    General Hood fought for which side in the Civil War?
    <form method="post" action="qtwo.php">
    <p>
    <input type="radio" name="qone" value="1">Union<br>
    <input type="radio" name="qone" value="2">Rebel<br>
    <input type="radio" name="qone" value="3">Patriot<br>
    <br>
    <button type="submit"><img src="submit.png"></button>
    </form>
    </p>
    </div>
    

     

    and

     

    $_POST['qone'] = $qone;
    include ('head.php');
    if ($qone == 2)
    {echo "<p>
    Your answer was correct!</p>";}
    else
    {echo "<p>
    Sorry, General Hood fought for the rebels or Confederates.</p>";}
    

  4. I keep getting a weird error like this:

    Warning: Cannot modify header information - headers already sent by (output started at /home/zyra/public_html/head.php:13) in /home/zyra/public_html/loginact.php on line 20

     

    I think it has something to do with some cookies I'm working with. Any insight?

×
×
  • Create New...