Jump to content

help with mysql/ if statement


MDanz

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.