Hey, I'm trying to determine if a table already exists in mysql, but doing a query first with mysql_query, then checking $sql as if it a were TRUE of FALSE. Which I though it would be. My Code always skips to the }else{ statment after the If(). What is wrong, How I do this?
I could of sworn I've wrote other scripts using this and it works.
PHP:
//Check first if it exists
$sql = mysql_query("SELECT var FROM fake WHERE token='{$token}'");
if( ! $sql){
// Does not exist! Create it.
$sql = mysql_query("INSERT INTO fake (var,token) VALUES('$var','$token')") ;
} else {
//It exists, Update it.
$sql = mysql_query("UPDATE fake SET var='{$var}' WHERE token='{$token}'") ;
}
Also
echo $sql; prints out, Resource id #11 or something.. Doesn't seem to say false or true....
This is driving me nuts!
This insert query looks to be alright, however I get this error:QuoteYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
'210010106140040100' == '210010106140040101'
Debugging this simple line of a PHP scriptCode: if($a == $b){ } I've found that with value of$a = '210010106140040100' (type = string)$b = '210010106140040101' (type = string)the result of the
Combining Two Queries
I have two scripts that each work fine by themselves. One is a search script with a variable that depends on what people search for. That will display results, but they are in a single column. I want
PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see when I view source, versus what I want to see … I am having image re-sizing issues that
get the country of visitor and display content based on that
Hello all,I have seen that Google analytics can tell you where a visitor is coming from and I want to do something similar. But I would like to add the functionality of redirecting a user based on his
is_dir() problem
Hello,I'm buidling a php scripts that dynamically get's subfolders from a specific folder.my code:Code: <?php if(isset($button)){ $opendirdepot =
Table colours fail when extra row added
Hey Gurus,I got a weird problem with formating the colour of a table made in php. Everything works fine when i use 5 rows each row has an alturnative colour, but when i add the 6th row the colour
Error: SQL Syntax; Line 1
Code: <?php require "global_settings.php"; ?><title><?php echo $sitetitle; ?></title><center><style
Posting to another Site?
I have software that people install.When they install it, is there a way to make it post their domain name to my website?I know I could do a header('location: http//www.mysite.com/id=?domain.com');
Mysql query, two times?
Hello to all,I'm new to php coding and i like it alot. I need help with some noob stuff.1. Having problem with mysql query after submiting HTML form. It's allways execuding two times, that way i have