Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
AD Gallery 67
SyntaxHighlighte... 51
Newsletters v4.03 114
Facebook Like Box 135
Newsletters v4.02 60
Metro 173
Facebook Connect 174
Shoutbox Panel 130
Redactor for PHP... 107
MI Floating Side... 109
Facebook Login/R... 156
Avatar Studio v2.03 180
Relationship Sta... 98
Sexual Orientati... 116
Fisherman 144
Popular Addons
iTheme2 5808
Arise 5808
User Control v1.23 4623
Event Calendar 4055
Photowidget panel 3889
Radio-Theme red2... 3360
Highslide Gallery 3315
CSS/JavaScript D... 3234
Facebook Connect... 2992
Dynamic Menu 2895
Slideshow Lightb... 2729
L-AMANT 2662
Enigma 2637
2Dark 2608
Black 2580
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.

$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'");
if ($uniqueCheck != 0) { echo "no matching thread subject found";}


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
}
?>



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


$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'");
if ($uniqueCheck == 0) {


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
 
http://www.fusiontube.co.uk/
PolarFox
$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'")?false:true;

 
http://unlogic.info
Wanabo
PolarFox wrote:

$uniqueCheck = dbcount("(forum_id)", DB_THREADS, "thread_subject='".$title."'")?false:true;


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

if $uniqueCheck = FALSE { do my php stuff }


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
Check theme before setting it Roadmap 1 09-05-2013 15:14
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
Ajax Username Availability Check Code Snippet and functions 32 27-10-2011 07:43
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 byVenue