...

View Full Version : Adnet service : out.php proble :(



markman
06-06-2005, 09:45 AM
Hello,
This is my first post in this splendid community, I hope I respect every rule.


<?php
include("connections/adnet.php");
$id = $_GET['id'];

if (empty($id)) {
echo ('Do not try to steel my scripts !!');
} else {
$checkid = mysql_query("SELECT * FROM website WHERE id='$id'");
$numid = mysql_num_rows($checkid);
if ($numid < 1) {
die('This id does not exist !!');
} else {
$array = mysql_fetch_array($checkid);
$out = $array['out'];
$newout = $out++;
$update = mysql_query("UPDATE `website` SET `out`='$newout' WHERE `id`='$id'") or die(' There has been an error processing your website'.mysql_error());
if (!$update) {
die('There has been an error, try again');
} else {
header("Location: $array[URL]");
}
}
}
?>

I don't get an error, but basically, out, which is currently 0, doesn't go to 1 !!
Please help me, there is no error, it goes correctly yo thr URL, but doesnt add anything :mad:

delinear
06-06-2005, 11:19 AM
I think from that code, $out is being assigned to $newout and THEN incremented afterwards. Try:


$out = $array['out'];
$out++;
$newout = $out;

Also I'm not sure the header redirect will work with the array[url]? Try either surrounding the $array with curly braces or closing the quotes, ie:


header("Location: {$array[URL]}");

or

header("Location: " . $array[URL]);

markman
06-06-2005, 11:32 AM
I think from that code, $out is being assigned to $newout and THEN incremented afterwards. Try:


$out = $array['out'];
$out++;
$newout = $out;

Also I'm not sure the header redirect will work with the array[url]? Try either surrounding the $array with curly braces or closing the quotes, ie:


header("Location: {$array[URL]}");

or

header("Location: " . $array[URL]);
Yay !!
It works !!
Thanks a lot !!
The header thing works okay, no problem, now I have a new problem :


<?php
session_start();
include("connections/adnet.php");

//variables
$creator = $_SESSION['username'];
$name = $_POST['name'];
$url = $_POST['URL'];
$null = "0";
$nothing = "0";

if ($_SESSION['username']) {
if (empty($name)) {
die('You have not put in a website name, try again');
}
if (empty($url)) {
die('You have not put in a website URL, try again');
}
$query = mysql_query("SELECT * FROM website WHERE URL='$url'");
$numquery = mysql_num_rows($query);
if ($numquery != 0) {
die('The website name or URL you have tried to put in already exist');
} else {
$insert = mysql_query("INSERT INTO website (URL, creator, in, out, website)
VALUES('$url', '$creator', '$null', '$nothing', '$name'") or die('There has been an error processing your submition'.mysql_error());

echo "Your website has been successfully\n added, add this code to your site :<br />\n";
$site = mysql_query("SELECT * FROM website WHERE URL='$url'");
$array = mysql_fetch_array($site);
?>
&lt;a href="out.php?id=<?php echo $array[id] ?>" target="_blank"&gt;<br />
&lt;img src="images/affiliates/flashindustriesbanner4.png" alt="Flashindustries" &gt;<br />
&lt;/a&gt;
<?php
}
} else {
die('You are not logged in !');
}
?>

It shows the following :


There has been an error processing your submitionYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'in, out, website) VALUES('test', 'markman', '0'

Please help me, I am really lost with MySQl and I have to finish this by Wednesday :( :( :(

delinear
06-06-2005, 12:14 PM
It looks like you're just missing a closing bracket inside the sql query, try the following I think it should fix the problem:


$insert = mysql_query("INSERT INTO website (URL, creator, in, out, website) VALUES('$url', '$creator', '$null', '$nothing', '$name')") or die('There has been an error processing your submition'.mysql_error());

markman
06-06-2005, 12:34 PM
Sorry, gives me the same stupid error as before :(
________________EDIT_____________
New script :


<?php
session_start();
include("connections/adnet.php");

//variables
$creator = $_SESSION['username'];
$name = $_POST['name'];
$url = $_POST['URL'];
$null = "0";
$nothing = "0";

if ($_SESSION['username']) {
if (empty($name)) {
die('You have not put in a website name, try again');
}
if (empty($url)) {
die('You have not put in a website URL, try again');
}
$query = mysql_query("SELECT * FROM website WHERE URL='$url'");
$numquery = mysql_num_rows($query);
if ($numquery != 0) {
die('The website name or URL you have tried to put in already exist');
} else {
$insert = mysql_query("INSERT INTO website (URL, creator, in, out, website) VALUES('$url', '$creator', '$null', '$nothing', '$name')") or die('There has been an error processing your submition'.mysql_error());

echo "Your website has been successfully\n added, add this code to your site :<br />\n";
$site = mysql_query("SELECT * FROM website WHERE URL='$url'");
$array = mysql_fetch_array($site);
?>
&gt;a href="out.php?id=<?php echo $array[id] ?>" target="_blank"&lt;<br />
&gt;img src="images/affiliates/flashindustriesbanner4.png" alt="Flashindustries" &lt;<br />
&gt;/a&lt;
<?php
}
} else {
die('You are not logged in !');
}
?>

mordred
06-06-2005, 02:20 PM
INSERT INTO website (URL, creator, in, out, website) VALUES('$url', '$creator', '$null', '$nothing', '$name')


The name of one of your table's fields conflicts with a reserved keyword in MySQL, namely 'in'. IN() is used to test whether a value belongs to a set of other values. If you have named your field like that, you need to put backticks around the field name in your query to not confuse the SQL parser:



INSERT INTO website (URL, creator, `in`, out, website) VALUES('$url', '$creator', '$null', '$nothing', '$name')

markman
06-07-2005, 05:44 AM
Thanks mordred, you guys are truly amazing people !

markman
06-07-2005, 05:48 AM
:thumbsup: Thanks mordred, you guys are truly amazing people ! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum