Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
hitwalker
Sells PC To Pay For Divorce



Joined:
Posts: 5661

PostPosted: Wed Nov 10, 2004 7:15 pm Reply with quote

Hi dont laugh cause ive never done this before...
but im trying to ad some info into a database....

this is the form....


Code:


<?
?>
Tekst toevoegen<br>
<form action="toevoegen.php" method="post">
Artist:<input type="text" name="titel" size="20" maxlength="20"><br>
Titel:<input type="text" name="artiest" size="30"><br>
Mixnaam:<input type="text" name="label" size="30"><br>
Hoogste positie:<input type="text" name="hp" size="30"><br>
Aw:<input type="text" name="aw" size="30"><br>

<input type="submit" name="submit" value="toevoegen"></form>

<?php

if($submit) {

mysql_connect("localhost","xxxxxx","xxxxxx");
mysql_select_db("xxxxxx");

$toevoegen = "INSERT INTO hits (id,titel,artiest,label,hp,aw)
VALUES ('','$id','$titel','$artiest','$label','$hp','$aw')";
$query = mysql_query($insert)or die(mysql_error());
}
?>


and this is the table...

Code:


CREATE TABLE `hits` (
  `id` int(11) NOT NULL default '0',
  `titel` varchar(250) NOT NULL default '',
  `artiest` varchar(250) NOT NULL default '',
  `label` varchar(150) NOT NULL default '',
  `hp` smallint(6) NOT NULL default '0',
  `aw` smallint(6) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;


i tried looking at examples ,i searched but all should be ok ?....but i cant get it to work....

first i had the error....Column count doesn't match value count at row 1...
But thats gone but now i have .....

"Query was empty"..

What is wrong with this ?

John[/b]
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Wed Nov 10, 2004 8:05 pm Reply with quote

Smack

Your query is named => $toevoegen but your insert statement is using =>$insert
Change this
$query = mysql_query($insert)
to
$query = mysql_query($toevoegen)

ROTFL
 
View user's profile Send private message
hitwalker







PostPosted: Wed Nov 10, 2004 8:18 pm Reply with quote

hi ,

well i had those already turned around to try ...
but now i get....

Column count doesn't match value count at row 1
 
Raven







PostPosted: Wed Nov 10, 2004 8:25 pm Reply with quote

You have 7 value columns in your values statement and only 6 column names
 
hitwalker







PostPosted: Wed Nov 10, 2004 8:27 pm Reply with quote

well what should i change ?
 
hitwalker







PostPosted: Wed Nov 10, 2004 9:05 pm Reply with quote

ah i know what you mean raven...yeah that was stupid....
anyway i got that changed now but now im facing the next problem.
info was added nicely without errors but when i try to add the second one i get....

Duplicate entry '0' for key 1

so how do i solve this....?
 
Raven







PostPosted: Wed Nov 10, 2004 9:12 pm Reply with quote

ID needs to be set up as an auto_increment field. Then the system will handle it.
 
hitwalker







PostPosted: Wed Nov 10, 2004 9:20 pm Reply with quote

ah thanks raven,that did it....
man and imagine how it must feel developing a big script from the bottom....
can be frustrating that it doesnt work because of a setting..... Confused
anyway thanks....im off to bed.......
 
chatserv
Member Emeritus



Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Thu Nov 11, 2004 7:03 am Reply with quote

Code:
<? 

?>
Tekst toevoegen<br>
<form action="toevoegen.php" method="post">
Artist:<input type="text" name="titel" size="20" maxlength="20"><br>
Titel:<input type="text" name="artiest" size="30"><br>
Mixnaam:<input type="text" name="label" size="30"><br>
Hoogste positie:<input type="text" name="hp" size="30"><br>
Aw:<input type="text" name="aw" size="30"><br>

<input type="submit" name="submit" value="toevoegen"></form>

<?php

if($submit) {

mysql_connect("localhost","xxxxxx","xxxxxx");
mysql_select_db("xxxxxx");

$toevoegen = "INSERT INTO hits (id,titel,artiest,label,hp,aw)
VALUES (NULL,'$titel','$artiest','$label','$hp','$aw')";
$query = mysql_query($toevoegen)or die(mysql_error());
}
?>
 
View user's profile Send private message Visit poster's website
hitwalker







PostPosted: Thu Nov 11, 2004 7:07 am Reply with quote

hi cs,

well as i wrote you the search doesnt work.
for example....i put in ...paul young - common people
and its added into the database but when i search it shows no results found.
and ive never touched any search form....
thats the weird part.. Sad
 
chatserv







PostPosted: Thu Nov 11, 2004 8:32 am Reply with quote

Maybe you should post the code you are using for the search.
 
hitwalker







PostPosted: Thu Nov 11, 2004 8:34 am Reply with quote

hi,

well there isnt any cause i need to completely strip the scripts i use...
the original search page is mixed with more stuff that isnt needed anymore...
so how hard can it be for a coder ? Razz
 
chatserv







PostPosted: Thu Nov 11, 2004 8:51 am Reply with quote

Oh, thought you had something because you said that when you search it shows no results found
 
hitwalker







PostPosted: Thu Nov 11, 2004 8:56 am Reply with quote

no it still su cks,all works but i need a search form that searches and displays the results...

the original search doesnt work in this way....

but the original table is this...

Code:


CREATE TABLE `hits` (
  `id` int(11) NOT NULL default '0',
  `titel` varchar(250) NOT NULL default '',
  `artiest` varchar(250) NOT NULL default '',
  `label` varchar(150) NOT NULL default '',
  `hp` smallint(6) NOT NULL default '0',
  `aw` smallint(6) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;



but the fields hp and aw wont be used anymore....
so maybe that will make any search form easier.... Sad
 
chatserv







PostPosted: Thu Nov 11, 2004 9:20 am Reply with quote

I have no way to verify this but at least it's a start, you can edit and debug it, in the search module find:
Code:
   if (is_active("Encyclopedia")) {

       $ecnt1 = $db->sql_query("SELECT eid from ".$prefix."_encyclopedia WHERE active='1'");
       $ecnt = 0;
       while($row_e = $db->sql_fetchrow($ecnt1)) {
                $eid = intval($row_e['eid']);
      $ecnt2 = $db->sql_numrows($db->sql_query("select * from ".$prefix."_encyclopedia WHERE title LIKE '%$query%' OR description LIKE '%$query%' AND eid='$eid'"));
      $ecnt3 = $db->sql_numrows($db->sql_query("select * from ".$prefix."_encyclopedia_text WHERE title LIKE '%$query%' OR text LIKE '%$query%' AND eid='$eid'"));
      $ecnt = $ecnt+$ecnt2+$ecnt3;
       }
       $mod3 = "<li> <a href=\"modules.php?name=Encyclopedia&amp;file=search&amp;query=$query\">"._ENCYCLOPEDIA."</a> ($ecnt "._SEARCHRESULTS.")";
   }

after add:
Code:
   if (is_active("Your_Modules_name")) {

       $lcnt = $db->sql_numrows($db->sql_query("SELECT * from ".$prefix."_hits WHERE titel LIKE '%$query%' OR artiest LIKE '%$query%'"));
            $x=0;
       $mod2 = "<li> Your_Module_Name ($lcnt "._SEARCHRESULTS.")";
            while($rowht = $db->sql_fetchrow($lcnt)) {
            echo " Titel: $rowht[titel] "
       ."Artiest: $rowht[artiest]<br>";
   }
                            $x++;
}
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©