Hi, I'm using 'submit article'. That all works, but now I want to check if that article already exists. So I want to use the field 'onderwerp' to check is it existst in 'jos_content'. I tried the following, but I just don't understand what I'm doing wrong.
I'm using the custom server side validation with this code:
I'm using the custom server side validation with this code:
<?php
$cf = JRequest::getString('title', '', 'onderwerp');
$db =& JFactory::getDBO();
$sql = "
SELECT COUNT(*)
FROM `jos_content`
WHERE `title` = ".$db->Quote($cf);
";
$db->setQuery($sql);
$result = $db->loadResult();
if ( $result ) {
return "This user is already in the database ";
}
?>
Hi proso,
That looks OK, try echoing out the value of $sql to see exactly what is being created - then test that in PHPMyAdmin to see if you get the expected result.
Bob
That looks OK, try echoing out the value of $sql to see exactly what is being created - then test that in PHPMyAdmin to see if you get the expected result.
Bob
Hi GreyHead,
I don't know how to do that. Could you point me in the right direction?
I don't know how to do that. Could you point me in the right direction?
Hi proso,
Something like this:
Bob
Something like this:
. . .
";
echo'<div>$sql: '.print_r($sql, true).'</div>';
$db->setQuery($sql);
. . .
Bob
I guess I'm to much of a noob for this. Is there an other method to check for duplicated articles? Maybe with DB record loader?
This topic is locked and no more replies can be posted.