E3pO Posted May 11, 2009 Share Posted May 11, 2009 Hello, I can't seam to figure out why this is erroring.. Any help would be greatly appreciated! <?php $url = (base64_decode($_GET['url'])); $ip = (base64_decode($_GET['ip'])); $value = "yes"; $link = mysql_connect('localhost', 'root', 'XXXXXDELETEDXXXXX'); mysql_select_db("XXXXXDELETEDXXXXX", $link) or die(mysql_error()); if(!is_resource($link)) { echo "Failed to connect to the server\n"; // ... log the error properly } else { // Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON. if(get_magic_quotes_gpc()) { $url = stripslashes(base64_decode($_GET['url'])); $ip = stripslashes(base64_decode($_GET['ip'])); } else { $url = (base64_decode($_GET['url'])); $ip = (base64_decode($_GET['ip'])); } // Make a safe query $query = sprintf("UPDATE sites SET show = '%s' WHERE url = '%s' AND ip = '%s'", mysql_real_escape_string($value, $link), mysql_real_escape_string($url, $link), mysql_real_escape_string($ip, $link)); mysql_query($query, $link) or die(mysql_error()); if (mysql_affected_rows($link) > 0) { echo "Product inserted\n"; } } ?> Returns this error: 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 'show = 'yes' WHERE url = 'http://ProxyNinja.com/' AND ip = 'deleted'' at line 1 http://xxxxxxxxxxx/prox/updateVerify.php?url=aHR0cDovL1Byb3h5TmluamEuY29tLw==&ip=ZGVsZXRlZA== SQL DATA: -- phpMyAdmin SQL Dump -- version 3.2.0-dev -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: May 11, 2009 at 04:18 PM -- Server version: 5.0.51 -- PHP Version: 5.2.4-2ubuntu5.6 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `deleted` -- -- -------------------------------------------------------- -- -- Table structure for table `sites` -- CREATE TABLE IF NOT EXISTS `sites` ( `id` int(11) NOT NULL auto_increment, `name` varchar(200) NOT NULL, `email` varchar(200) NOT NULL, `url` varchar(200) NOT NULL, `details` text NOT NULL, `ip` varchar(200) NOT NULL, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, `show` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Dumping data for table `sites` -- INSERT INTO `sites` (`id`, `name`, `email`, `url`, `details`, `ip`, `timestamp`, `show`) VALUES (5, 'ProxyNinja', 'ProxyNinja@atspam.info', 'http://ProxyNinja.com/', 'Feel free to browse the internet at school with ProxyNinja.com to unblock websites like Myspace, Bebo, Facebook, Friendster, hi5 and more!', 'deleted', '2009-05-11 01:41:11', ''); Quote Link to comment https://forums.phpfreaks.com/topic/157727-solved-updating-sql-data-error/ Share on other sites More sharing options...
premiso Posted May 11, 2009 Share Posted May 11, 2009 I am sure "Show" is a reserved word: $query = sprintf("UPDATE sites SET `show` = '%s' WHERE url = '%s' AND ip = '%s'" You need to encase it in backticks (`) for it to work or rename it. Quote Link to comment https://forums.phpfreaks.com/topic/157727-solved-updating-sql-data-error/#findComment-831895 Share on other sites More sharing options...
E3pO Posted May 11, 2009 Author Share Posted May 11, 2009 Amazing!! Thank you very much!!!! Added PHPFreaks link to front page!!!! http://proxy.wmclan.net/ Thank you very much premiso. Quote Link to comment https://forums.phpfreaks.com/topic/157727-solved-updating-sql-data-error/#findComment-831902 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.