Jump to content

[SOLVED] Updating SQL Data. Error?


E3pO

Recommended Posts

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', '[email protected]', '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', '');

Link to comment
https://forums.phpfreaks.com/topic/157727-solved-updating-sql-data-error/
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.