Re: Me again...

From: Date: Mon, 24 Feb 2003 21:30:30 +0000
Subject: Re: Me again...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136886@lists.php.net to get a copy of this message
At 03:48 24/02/03, you wrote:
Hi, please see the following red code... (i get plain text, so not red)
it adds info to a MySQL Table called "Schools". Whats the problem? Although the first time you execute it, it works, after the first time you send the form you get ERROR.
    $qs = 'INSERT INTO Schools (LongName, Abbreviation) VALUES (' .
      "'" . addslashes(trim($longname)) . "'," .
      "'" . addslashes(trim($abbrev)) . "')";
    if(!mysql_query($qs, $db))
      echo '<font color="red"><b>Error</b></font><br />';
------------------- KEY Approved (Approved), KEY ShortName (ShortName), UNIQUE ShortName_2 (ShortName) It seems that the problem resides in ShortName.... but I still don´t understand what to do... i guess that ShortName_2 is the problem, since it needs to be unique and the first time you enter the form it enters a data set or row with Shortname_2 empty, and the second time you try it is still empty.
When developing a script, try
     echo '<font color="red"><b>Error: '.mysql_error().'</b></font><br />';
to see mysql's reactions. or $result=mysql_query($qs,$db)
     or die ('<br><font color=red>Error in '.__FILE__.' line '.__LINE__.'<br>Query was:'.$qs.'<br>Mysql error:'.mysql_error()):
PS please choose a better title than 'Me again...'

« previous php.general (#136886) next »