0

I have some code that will automatically assign a certain number of plates when entered in the field $num_plates. However, when looping the mysql_query only works once:

$region = $_POST['region'];
$num_plates = $_POST['num_plates']; //4

$prfx = 'AAA';
$sffx = '1001';
$c = 1;

while($c <= $num_plates) 
{
    $prfx = ++$prfx;
    $sffx = ++$sffx;

    mysql_query("INSERT INTO v_info (`plate_prefix`, `plate_suffix`, `region`, `status`) 
                 VALUES ('$prfx', '$sffx', '$region', 'Available')");

    $c = $c+1;
    echo "<h1 align='center'>".$c."</h1>";
}
Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
gauche23
  • 67
  • 1
  • 4
  • 1
    your first problem, you are using mysql_, [don't use mysql_*](http://stackoverflow.com/a/12860046/1028804) – Memor-X Dec 08 '15 at 00:43

1 Answers1

1

Multiple queries are explicitly not supported by mysql_query. From the manual:

mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

On the other hand, mysqli does support multiple queries. You need to use that.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102