Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Follow us on Facebook
Follow us on Google+
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Code Snippet and functions
Who is here? 1 guest(s)
 Print Thread
How to check if a thread_subject already exists in DB_THREADS
Wanabo
I need to check if a thread_subject already exists in DB_THREADS

I thought this code would work but it does not work. Obviously the $title variable needs to be checked against existing thread_subjects.

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'");
if ($uniqueCheck != 0) { echo "no matching thread subject found";}
[/syntaxhighlighter]

The uniqueCheck was taken from forums.php

Who can help me out?
Edited by Wanabo on 10-12-2011 00:33
KPN Gebruikers Groep, my largest pHp-Fusion site about an ISP.
pHp-Fusion.Org, tutorials to enhance php-fusion.
pHp-Fusion.Asia & pHp-Fusion.Fr & pHp-Fusion.Cn are available for a localized support site. Send PB for info.
 
http://ziggo.gebruikers.eu
Craig
Download source  Code
<?php
$subject ="The Thread Subject Here"; // Thread subject
$check = dbquery("SELECT thread_subject FROM ".DB_THREADS." WHERE thread_subject='".$subject."'");
if (dbrows($check) > 0) {
echo"True"; // If Result True
}else{
echo"False"; // If Result False
}
?>



Regards
 
http://www.phpfusionmods.co.uk/
Wanabo
Thanks, but I just figured out an other solution. :)

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'");
if ($uniqueCheck == 0) {
[/syntaxhighlighter]

It was this != versus == thing that got me on the wrong foot.
Edited by Wanabo on 10-12-2011 00:59
KPN Gebruikers Groep, my largest pHp-Fusion site about an ISP.
pHp-Fusion.Org, tutorials to enhance php-fusion.
pHp-Fusion.Asia & pHp-Fusion.Fr & pHp-Fusion.Cn are available for a localized support site. Send PB for info.
 
http://ziggo.gebruikers.eu
Craig
Cool! Smile
Regards
 
http://www.phpfusionmods.co.uk/
PolarFox
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'")?false:true;[/syntaxhighlighter]
 
http://unlogic.info
Wanabo
PolarFox wrote:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'")?false:true;[/syntaxhighlighter]


Thanks Polarfox. I'm not so familiar with switches so to use the switch it would be something like this.

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]if $uniqueCheck = FALSE { do my php stuff }[/syntaxhighlighter]

Hint for developers: if syntaxhighlighter (or other bbcode for code is used) disable smileys.
KPN Gebruikers Groep, my largest pHp-Fusion site about an ISP.
pHp-Fusion.Org, tutorials to enhance php-fusion.
pHp-Fusion.Asia & pHp-Fusion.Fr & pHp-Fusion.Cn are available for a localized support site. Send PB for info.
 
http://ziggo.gebruikers.eu
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
user check User Administration 2 15-10-2013 15:48
Check theme before setting it Roadmap 4 27-05-2013 01:21
How to check if group exist? Panels and Infusions 1 14-08-2012 17:00
How to check if user is admin? Panels and Infusions 15 08-08-2012 13:57
check us out Post Your Site 1 04-04-2012 03:10
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel fromVenue