Jump to content

[SOLVED] Php parse not working


DrTrans

Recommended Posts

$connect = mysql_connect("localhost","damgears_evil","****");
    mysql_select_db("damgears_evil", $connect);
        $result = mysql_query("SELECT * FROM sales WHERE key = '$key'");
        if (mysql_num_rows($result)== FALSE)
        {
            echo "Error: Contact Affliction Lexington.";
            mysql_close($connect);
        }
        else
        {
           
	   $queryb = mysql_query("INSERT INTO titles VALUES ('','$fname','$lname','$key','$slname','$skey','$date','$striped','$region')");
		mysql_close($connect);
        echo "$title";
	}

 

basically what i want to do here is if there are no records in the sales table for that key . then echo" Error" . if there is a key that matchs.. insert record.

 

Please help.

Link to comment
https://forums.phpfreaks.com/topic/178708-solved-php-parse-not-working/
Share on other sites

the connection works and so does the select:

 

I replaced the code with this

 

if($title){
  
    
    
 echo "$title";
 $connect = mysql_connect("localhost","damgears_evil","damgears");
     mysql_select_db("damgears_evil");
    // $queryb = mysql_query("INSERT INTO titles VALUES (fname, lname, key, sname, skey, date, title, region) VALUES ('$fname','$lname','$key','$slname','$skey','$date','$title','$region')");
     $queryb = mysql_query("INSERT INTO titles VALUES ('','$fname','$lname','$key','$slname','$skey','$date','$striped','$region')");
      mysql_close($connect);
   } else 
   echo"Problem.. Check Database";

 

And it inserts the information just fine into the "titles" table.

 

However like i said, Im wanting to check to make sure the " Sale" has happened before it inserts into the "titles" table. by using that SELECT * FROM sales WHERE key = '$key'

 

In my sales table i have

 

fname

lname

key

date

region

 

 

Hi DrTrans,

 

The problem is occuring because you are using the reserved word "key" in your statement.  When using reserved words you must escape them with backticks, i.e. `key`.

 

Click here for further information on MySQL reserved words.

 

Hope this helps.

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.