lJesterl Posted November 18, 2006 Share Posted November 18, 2006 here is the code im using<?php$con = mysql_connect("localhost","dnuname","dbpass");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("dbname", $con);mysql_query("UPDATE debrackets SET tid='$_POST[tid]' WHERE tid='$tid'");if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "<center><br><br><br>";echo "<font color=white>Brackets Where Updated<br>"mysql_close($con)?>Its not going into the mysql because the table is empty. What i want to do is either A)INSERT INTO debrackets blah blahbut if it existUPDATE debrackets SET blah blahorB) UPDATE debrackets SET blah blahbut if it doesnt exisitINSERT INTO debrackets blah blahAny Ideas? Link to comment https://forums.phpfreaks.com/topic/27653-error-query-was-empty-help/ Share on other sites More sharing options...
trq Posted November 18, 2006 Share Posted November 18, 2006 Both your A) and B) options are the same. The logic is simple.First, run a SELECT query to see if the record already exists, if it does, form an UPDATE statement otherwise form an INSERT.It seems you have a basic understanding of the functions required so now that you have the logic, it shouldn't be too hard to help yourself. Link to comment https://forums.phpfreaks.com/topic/27653-error-query-was-empty-help/#findComment-126492 Share on other sites More sharing options...
Psycho Posted November 18, 2006 Share Posted November 18, 2006 Or just use a INSERT with the ON DUPLICATE KEY UPDATE option Link to comment https://forums.phpfreaks.com/topic/27653-error-query-was-empty-help/#findComment-126519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.