MDanz Posted March 25, 2010 Share Posted March 25, 2010 having trouble getting this working. It should check to see if the username is found. If it isn't found, It should insert a new row into the contribute table. i think i did check if username is found wrong <?php $username=$_SESSION['username']; $found = $_GET['c']; if($found="1"){ $contribute = $_SESSION['contribute']; mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $title = mysql_query("SELECT username FROM Contribute WHERE username='$username'")or die (mysql_error()); while($titlerow = mysql_fetch_assoc($title)){ $notfound = $titlerow['username']; } if(empty($notfound)){ mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $keywords = mysql_real_escape_string($_POST['keywords']); $query = "INSERT INTO Stacks"; $query .= "(`username`,`stack`) VALUES ('$username','$keywords')"; mysql_query($query); } } ?> Link to comment https://forums.phpfreaks.com/topic/196440-help-with-mysql-if-statement/ Share on other sites More sharing options...
o3d Posted March 25, 2010 Share Posted March 25, 2010 Just check if($found="1"){ Think it should be $found == "1" Link to comment https://forums.phpfreaks.com/topic/196440-help-with-mysql-if-statement/#findComment-1031439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.