Click to See Complete Forum and Search --> : Problems with "unique" attribute


Perfidus
11-20-2003, 04:59 AM
I'm storing the session_id() value in a database and I have set attribute "unique" for this field. I have a form and the users can log in but when they use the back button of the browser or they logg twice without closing the browser, they get a Mysql error message of "duplicate entry".
Is there a way to customize this message or to send them to another page?

pyro
11-20-2003, 07:22 AM
Before you do your INSERT query, you could check to see if the session exists in the DB.

Perfidus
11-20-2003, 09:16 AM
I will try.
Do you know why I get this error making a query in 2 tables?

THE QUERY (LINE 22 as error saids):
$result = mysql_query("SELECT * FROM Precios, Disponibilidad WHERE (Ref='$Ref')", $link);
while($row = mysql_fetch_array($result)) {
echo $row["ene2"];
}


THE ERROR:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /chs/p1/costa4seasons.com/home/html/changes.html on line 22

pyro
11-20-2003, 10:11 AM
If your tables have columns with the same name, you'll have to use the dot syntax (table.column).

For instance:

"SELECT * FROM `Precios`, `Disponibilidad` WHERE `Precios.Ref`='$Ref'"

Perfidus
11-20-2003, 10:26 AM
Only one column has the same name (first one) and I'm not querying this column, the rest have different names.
I still don't know why it gaves me an error, sintx seem to be OK.