my800stuff Posted January 31, 2009 Share Posted January 31, 2009 Here is my script and Here is the error: Cannot query the database. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET ='http://www.mydomain.com/host', ='/home/mydomain/public_html/ho' at line 1 This is part of my functions.php <?php include '../../inc/sqlinf.php'; $a = $_POST['1']; $b = $_POST['2']; $c = $_POST['3']; $d = $_POST['4']; $e = $_POST['5']; $f = $_POST['6']; $g = $_POST['7']; $h = $_POST['8']; $i = $_POST['9']; $j = $_POST['10']; if ($edit == 'tru') { $v ="UPDATE $which SET"; $w =" WHERE ID = '$id'"; }else{ $v ="INSERT INTO $which SET"; $w = $nil; } if (empty($b)) {$bc = $no; } else {$bc=',';} if (empty($c)) {$cc = $no; } else {$cc=',';} if (empty($d)) {$dc = $no; } else {$dc=',';} if (empty($e)) {$ec = $no; } else {$ec=',';} if (empty($f)) {$fc = $no; } else {$fc=',';} if (empty($g)) {$gc = $no; } else {$gc=',';} if (empty($h)) {$hc = $no; } else {$hc=',';} if (empty($i)) {$ic = $no; } else {$ic=',';} if (empty($j)) {$jc = $no; } else {$jc=',';} if (empty($k)) {$kc = $no; } else {$kc=',';} if (empty($a)) {$t1= $nono; $q1 = $abc; $q2 = $def;}else{$q1a="'"; $q2a="=";} if (empty($b)) {$t2= $nono; $q1 = $abc; $q2 = $def;}else{$q1b="'"; $q2b="=";} if (empty($c)) {$t3= $nono; $q1 = $abc; $q2 = $def;}else{$q1c="'"; $q2c="=";} if (empty($d)) {$t4= $nono; $q1 = $abc; $q2 = $def;}else{$q1d="'"; $q2d="=";} if (empty($e)) {$t5= $nono; $q1 = $abc; $q2 = $def;}else{$q1e="'"; $q2e="=";} if (empty($f)) {$t6= $nono; $q1 = $abc; $q2 = $def;}else{$q1f="'"; $q2f="=";} if (empty($g)) {$t7= $nono; $q1 = $abc; $q2 = $def;}else{$q1g="'"; $q2g="=";} if (empty($h)) {$t8= $nono; $q1 = $abc; $q2 = $def;}else{$q1h="'"; $q2h="=";} if (empty($i)) {$t9= $nono; $q1 = $abc; $q2 = $def;}else{$q1i="'"; $q2i="=";} if (empty($j)) {$t10=$nono; $q1 = $abc; $q2 = $def;}else{$q1j="'"; $q2j="=";} $sql = "$v $t1 $q2a$q1a$a$q1a$bc $t2 $q2b$q1b$b$q1b$cc $t3 $q2c$q1c$c$q1c$dc $t4 $q2d$q1d$d$q1d$ec $t5 $q2e$q1e$e$q1e$fc $t6 $q2f$q1f$f$q1f$gc $t7 $q2g$q1g$g$q1g$hc $t8 $q2h$q1h$h$q1h$ic $t9 $q2i$q1i$i$q1i$jc $t10 $qj$q1j$j$q1j$kc $w "; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); $variable = "../$return.php"; include '../resend.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/ Share on other sites More sharing options...
corbin Posted January 31, 2009 Share Posted January 31, 2009 Did you read the error? You have a syntax error in your query, so your first step should be to echo it out and see what it looks like. Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-751405 Share on other sites More sharing options...
Snart Posted January 31, 2009 Share Posted January 31, 2009 From watching that error, I'd say your query doesn't contain any column names. You're setting new values, but there are no column names before the equal signs so it doesn't now which columns to update. Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-751454 Share on other sites More sharing options...
FezEvils Posted January 31, 2009 Share Posted January 31, 2009 try to combine $v and $w together... if you want to separate it, must use: $v.="statement1"; $v.="statement2"; Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-751481 Share on other sites More sharing options...
my800stuff Posted February 1, 2009 Author Share Posted February 1, 2009 I'm a bit lost I'm not sure which instructions to follow and the last one about combining them... I'm not sure how to I'm using this script I didn't write it I'm trying to figure out whats wrong with it so I can get it working. I'm not so good at writting code or programming sql/php stuff. I figured it would just work. Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-751794 Share on other sites More sharing options...
fenway Posted February 2, 2009 Share Posted February 2, 2009 OMG... can you actually understand any of your own code? No offense, but that's brutal. Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-752469 Share on other sites More sharing options...
Maq Posted February 2, 2009 Share Posted February 2, 2009 I'm a bit lost I'm not sure which instructions to follow and the last one about combining them... I'm not sure how to I'm using this script I didn't write it I'm trying to figure out whats wrong with it so I can get it working. I'm not so good at writting code or programming sql/php stuff. I figured it would just work. Little off topic but, do you mind disclosing where you got this script from? Did you pay for it? Did someone write it for you? Did you steal it? Why don't you ask them? Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-752837 Share on other sites More sharing options...
MadTechie Posted February 3, 2009 Share Posted February 3, 2009 that has to be a obfuscate script! Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-753122 Share on other sites More sharing options...
Maq Posted February 3, 2009 Share Posted February 3, 2009 that has to be a obfuscate script! lol, yeah obfuscate.php Maybe there's a legit reason for him not knowing how this script works... Why can't you go back to the author and ask him to fix it? It's hard for us to help you if you don't know anything about your code... Plus the format is hard to follow. Quote Link to comment https://forums.phpfreaks.com/topic/143229-cannot-query-the-database/#findComment-753518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.