Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

mySQL Hates Me Can't Insert Into Table

$
0
0

I'm trying to insert two variables into a table, but the first field always ends up empty, while the second one turns out correct. 

 

The entire script goes:

<?php

$id = $_POST['id'];

mysql_connect("localhost", "*****", "******") or die(mysql_error());
mysql_select_db("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());


$key = rand(1,146);

$x=1;
while($x<95){

$result = mysql_query("SELECT * FROM Letters");
$row = mysql_fetch_array($result);
$entry =$row['letters'];

$queryb = "SELECT * FROM Permutations WHERE Number=$key";
$resultb = mysql_query($queryb) or die(mysql_error());
$rowb = mysql_fetch_array($resultb) or die(mysql_error());
$entryb = $rowb['Permutations'];

$queryc="INSERT INTO $id(letter,code) VALUES ('$entry','$entryb')";
mysql_query($queryc)or die(mysql_error());

$x=$x+1;
$key = $key+1;
}

?>

The column "letter" is always empty, but I'm sure that $entry has values in it!

 

Please help, this is for a science fair project that's due in two days.


Viewing all articles
Browse latest Browse all 13200

Trending Articles