Error with code - text followed by database entry

Hi there,

I want to enter a code into a MySQL database. I want it to start and continue like this:


I will code it to always display “AGPS-”

In the MySQL database I will store 1000000. Then auto-increment it.

The problem is with coding the retrieval of the code:

This does not work:

The code $ThisVendorTxCode = "AGPS-"$row["vendor"];

This code works:

$ThisVendorTxCode = "AGPS-";

but it does not get the vendor code because the “;” ends the request. But without it it says there is an error in the code.

How do I get the AGPS- at the start followed by what is in the database? How do I code it?


You should use the concatenation operator. Try “AGPS-” . $row[‘vendor’];

OK - thanks for that. it is working well now.

But my problem now is i get this error my PHPMyAdmin

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

how do i auto-increment more than one?

Why do you need to auto-increment more than one?

You can’t. Why would you want more than one autoincrement column in one table?

I’ll use the one.

You can also solve this on database level, which should be more efficient:

If you auto-increment on column vendor:

SELECT CONCAT("AGPS-", vendor) AS vendor

If you auto-increment on column id, and where id equals the last digits in vendor:

SELECT CONCAT("AGPS-", 1000000 + id) AS vendor

Alternately (likely slower, but also more versatile if you can’t use simple addition):

SELECT CONCAT("AGPS-1", LPAD(id, 6, "000000")) AS vendor