Jump to content

Help please with my Banner Script


yellowking

Recommended Posts

Hi,

I appreciate any help anyone can give me here I hope I'm in the right section for this.

I am trying to add banners to my site via php and the code I have keeps coming up with the followng error.

Error in SQL query. Cannot add Banner. Please contact with administrator. MySQL:
Column count doesn't match value count at row 1

Can someone please check it and let me know what I need to change to get it working.

Here is the code<?php
require_once('../config/config.php');
require_once('../config/func.php');

$a=$_GET['a']; ?><?php
require_once('../config/config.php');
require_once('../config/func.php');

$a=$_GET['a']; $id=$_POST['id'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>banners</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link href="../config/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<base target="main">

<div class="admin">BANNERS<?php print(($a=='del') ? ' - DELETING' : ' - ADDING'); ?></div><br><br>

<?php
if (auth())
{
if ($a=='del')
{
if ($result=mysql_query("SELECT `id_banner`, `url` FROM `banners` ORDER BY `id_banner` DESC"))
{
if (mysql_num_rows($result)>0)
{
print ('<form method="post" style="text-align:center"><select name="id">');
while ($row=mysql_fetch_assoc($result))
{
print('<option value="'.$row['id_banner'].'"'.(($id==$row['id_banner']) ? ' selected' : '').'>'.$row['url'].'</option>');
}
print ('</select>&nbsp;&nbsp;<input type="submit" value=" DELETE "></form>');
mysql_free_result($result);
}
else
error('No data in database');
}
else
error('Error in SQL query! MySQL:<br>' . mysql_error());


// delete
if (!empty($id))
{
if ($_POST['del']=='yes')
{
if (mysql_query("DELETE FROM `banners` WHERE `id_banner`='$id'"))
{
switch_page('banners.php?a=del', 'Deleted banner');
}
else
error('Error in SQL query. Cannot delete program. Please contact with administrator. MySQL:<br>' . mysql_error() . '<br><br><a href="javascript:history.go(-1)">return</a>');
}
else
{
?>
<form method="post" style="text-align:center">
<input type="hidden" name="id" value="<?=$id ?>">
<input type="hidden" name="del" value="yes">
Are you sure you want to delete?<br>
<input type="button" value=" NO " onClick="location.href='banners.php/a=del">&nbsp;
<input type="submit" value=" YES ">
</form>
<?php
}
}

}


if ($a=='add')
{
$link=$_POST['link']; $url=$_POST['url']; $opis=str_replace('"', '&quot;', $_POST['opis']);
if (strlen($link) && strlen($url) && strlen($opis))
{
if (mysql_query("INSERT INTO `banners` VALUES('', '$url', '$link', '$opis')"))
switch_page('banners.php?a=add', 'Added banner');
else
error('Error in SQL query. Cannot add Banner. Please contact with administrator. MySQL:<br>' . mysql_error() . '<br><br><a href="javascript:history.go(-1)">return</a>');
}
else
{
if ($_POST['go']=='yes')
error('You must fill all fields');
?>
<form method="post">
<input type="hidden" name="go" value="yes">
<table>
<tr><td>URL page:</td><td><input type="text" name="link" value="<?php print($link); ?>" maxlength="200" size="70"></td></tr>
<tr><td>URL banner:</td><td><input type="text" name="url" value="<?php print($url); ?>" maxlength="100" size="70"></td></tr>
<tr><td>Descripion:</td><td><textarea name="opis" cols="66" rows="8"><?php print($opis); ?></textarea></td></tr>
<tr><td></td><td><input type="submit" value=" ADD BANNER "></td></tr>
</table>
</form>
<?php
}
}

}
?>

</body>
</html>


Link to comment
Share on other sites

  • 3 weeks later...
Hi.

If i read the error from mysql correct, than you have to check the db with phpmyadmin, to see if the tables in the db are what the scripts demands. i.e. if the script requires a table with the name "banner", and that table has 5 rows, check if the rows have any values or data in them. You will get that error if your db is not according to the scripts demand. You could try to delete the tables in the db, then consult your scripts innstall help files. If that does`nt work, try deleting the entire db and create it from scratch.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.