i put in the action Custom Server Side Validation these code
<?php
// Acquisisco il numero di telaio
$ntelaio=$form->data['ntelaio'];
$controllo = "SELECT * FROM name_table WHERE ntelaio = '$ntelaio'";
$risultato = mysql_query($controllo);
if (mysql_num_rows($risultato) <>$ntelaio){
$form->validation_errors['ntelaio']= "Numero di telaio con garanzia attiva";
return false;
}
?>
but don't work very weell, because when i test it , comeback these word
Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /web/htdocs/www.redmoto.it/home/rivenditori/administrator/components/com_chronoforms/form_actions/custom_serverside_validation/custom_serverside_validation.php(19) : eval()'d code on line 15 Warning: mysql_query(): A link to the server could not be established in /web/htdocs/www.redmoto.it/home/rivenditori/administrator/components/com_chronoforms/form_actions/custom_serverside_validation/custom_serverside_validation.php(19) : eval()'d code on line 15 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /web/htdocs/www.redmoto.it/home/rivenditori/administrator/components/com_chronoforms/form_actions/custom_serverside_validation/custom_serverside_validation.php(19) : eval()'d code on line 17
the same situation on another site joomla 2.5 and chronoform V4 work very very well😲
Thanks in advance!
Best Regards
I suggest that you change your code to use the Joomla db class:
<?php
$ntelaio=$form->data['ntelaio'];
$database = JFactory::getDBO();
$controllo = "SELECT * FROM name_table WHERE ntelaio = '$ntelaio'";
$database->setQuery($controllo);
$risultato = $database->loadAssocList();
if (mysql_num_rows($risultato) <>$ntelaio){
$form->validation_errors['ntelaio']= "Numero di telaio con garanzia attiva";
return false;
}
?>
it may need 1 more fix in your "if" statement!
Regards,
Max
I change the db connect, but now comeback these error
Warning: mysql_num_rows() expects parameter 1 to be resource, array given in /web/htdocs/www.redmoto.it/home/rivenditori/administrator/components/com_chronoforms/form_actions/custom_serverside_validation/custom_serverside_validation.php(19) : eval()'d code on line 17
Thanks
King Regards
you may try
count($risultato)
instead, also whats "<>" ???
Regards,
Max
if any -> error message this value already exists
if there is not okay, and enter the value in the table
Thank
Regards
Marco
if(count($risultato))