dbTalk Databases Forums  

syntax error re increment?

comp.databases.mysql comp.databases.mysql


Discuss syntax error re increment? in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Geoff
 
Posts: n/a

Default syntax error re increment? - 01-15-2011 , 01:15 PM






Hello

I have a htm with a URL

new-links.php?id=4

The new-links.php code is as follows - but I get a syntax error
reported "near out=out+1 WHERE ID=4".

Any idea why?!

Cheers

Geoff

<?php
// Connects to your Database
@require(dirname(__FILE__) . '/cgi-bin/config.php');

$id = $_GET['id'];

mysql_connect($conf['sql']['host'], $conf['sql']['user'],
$conf['sql']['pass']) or die(mysql_error());
mysql_select_db($conf['sql']['db']) or die(mysql_error());

//Adds to the click count for a particular link
mysql_query("UPDATE links SET out=out+1 WHERE ID = $id")or
die(mysql_error());

//Retrieves information
$data = mysql_query("SELECT * FROM links WHERE ID = $id") or
die(mysql_error());
$info = mysql_fetch_array($data);

//redirects them to the link they clicked
header( "Location:" .$info['URL'] );
?>

Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: syntax error re increment? - 01-15-2011 , 02:08 PM






On 1/15/2011 2:15 PM, Geoff wrote:
Quote:
Hello

I have a htm with a URL

new-links.php?id=4

The new-links.php code is as follows - but I get a syntax error
reported "near out=out+1 WHERE ID=4".

Any idea why?!

Cheers

Geoff

?php
// Connects to your Database
@require(dirname(__FILE__) . '/cgi-bin/config.php');

$id = $_GET['id'];

mysql_connect($conf['sql']['host'], $conf['sql']['user'],
$conf['sql']['pass']) or die(mysql_error());
mysql_select_db($conf['sql']['db']) or die(mysql_error());

//Adds to the click count for a particular link
mysql_query("UPDATE links SET out=out+1 WHERE ID = $id")or
die(mysql_error());

//Retrieves information
$data = mysql_query("SELECT * FROM links WHERE ID = $id") or
die(mysql_error());
$info = mysql_fetch_array($data);

//redirects them to the link they clicked
header( "Location:" .$info['URL'] );
?
Out is a reserved word.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #3  
Old   
Geoff
 
Posts: n/a

Default Re: syntax error re increment? - 01-15-2011 , 03:02 PM



On Sat, 15 Jan 2011 15:08:53 -0500, Jerry Stuckle
<jstucklex (AT) attglobal (DOT) net> wrote:

Quote:
On 1/15/2011 2:15 PM, Geoff wrote:
Hello

I have a htm with a URL

new-links.php?id=4

The new-links.php code is as follows - but I get a syntax error
reported "near out=out+1 WHERE ID=4".

Any idea why?!

Cheers

Geoff

?php
// Connects to your Database
@require(dirname(__FILE__) . '/cgi-bin/config.php');

$id = $_GET['id'];

mysql_connect($conf['sql']['host'], $conf['sql']['user'],
$conf['sql']['pass']) or die(mysql_error());
mysql_select_db($conf['sql']['db']) or die(mysql_error());

//Adds to the click count for a particular link
mysql_query("UPDATE links SET out=out+1 WHERE ID = $id")or
die(mysql_error());

//Retrieves information
$data = mysql_query("SELECT * FROM links WHERE ID = $id") or
die(mysql_error());
$info = mysql_fetch_array($data);

//redirects them to the link they clicked
header( "Location:" .$info['URL'] );
?

Out is a reserved word.
Brilliant ! Thanks Jerry.

Cheers

Geoff

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.