yellowking Posted December 17, 2006 Share Posted December 17, 2006 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 1Can someone please check it and let me know what I need to change to get it working.Here is the code<?phprequire_once('../config/config.php');require_once('../config/func.php');$a=$_GET['a']; ?><?phprequire_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><?phpif (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> <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"> <input type="submit" value=" YES "> </form> <?php } } } if ($a=='add') { $link=$_POST['link']; $url=$_POST['url']; $opis=str_replace('"', '"', $_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> Quote Link to comment https://forums.phpfreaks.com/topic/31016-help-please-with-my-banner-script/ Share on other sites More sharing options...
xprez Posted January 8, 2007 Share Posted January 8, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/31016-help-please-with-my-banner-script/#findComment-155771 Share on other sites More sharing options...
yellowking Posted January 8, 2007 Author Share Posted January 8, 2007 xprezThanks for coming back to me I'll try that later on and will let you know how I get on.Many thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/31016-help-please-with-my-banner-script/#findComment-155805 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.