/    Sign up×
Community /Pin to ProfileBookmark

databse not adding?

for some reason my script is not adding any info to the database

my code

[code=php]
<?php
ob_start();
session_start();
include(‘common/connect.php’);

$to = $_GET[‘site’];
$browser = $_SERVER[“SCRIPT_URI”];
$ip = $_SERVER[‘REMOTE_ADDR’];
$banner = $_SERVER[‘HTTP_REFERER’];
$site = “http://www.slweb.co.nz/”;
$today = date(Ymd);

$add = “INSERT INTO `advertisers` (domain,ip,browser,site,to,date) VALUES (‘$banner’,’$ip’,’$browser’,’$site’,’$to’,’$today’)”;
$result = @mysql_query($add);
echo(mysql_error());

header(“Location: {$to}”);

?>
[/code]

the table structure

[code]
Field Type Null Default
id int(10) No
domain varchar(255) No
ip varchar(255) No
browser varchar(255) No
site varchar(200) No
to varchar(80) No
date date No 0000-00-00
[/code]

I also dont think most of the $SERVER vars are being set either?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@purefanNov 25.2005 — I am not sure but I think you are 'mysqling' wrong.

Ive always used it like this:
[code=php]
mysql_query($query) or die('<h1><font color="#FF0000">Error...</font></h1><br>' . mysql_errno() . ': ' . mysql_error() . '. Could not add. <br>tell me plz: [email protected]');
[/code]

instead of your:

$result = @mysql_query($add);

echo(mysql_error());
[/quote]


If you are not sure if the vars are coming ok then you could also print them before adding for debugging purposes.
Copy linkTweet thisAlerts:
@chazzyNov 25.2005 — i hate error supression, it's good for production apps but not for development. you gotta figure out what error you're getting back.

oh, try changing your date format to Y-m-d

2nd edit: oh and why not just change the date default to CURDATE() and just skip trying to insert it? and i don't see anything on id saying it's auto increment. it's listed as being not null, but you don't have a value...
×

Success!

Help @Sheldon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...