Author |
Message |
hitwalker
Sells PC To Pay For Divorce

Joined:
Posts: 5661
|
Posted:
Wed Nov 10, 2004 7:15 pm |
|
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] |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Nov 10, 2004 8:05 pm |
|
Your query is named => $toevoegen but your insert statement is using =>$insert
Change this
$query = mysql_query($insert)
to
$query = mysql_query($toevoegen)
 |
|
|
|
 |
hitwalker

|
Posted:
Wed Nov 10, 2004 8:18 pm |
|
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

|
Posted:
Wed Nov 10, 2004 8:25 pm |
|
You have 7 value columns in your values statement and only 6 column names |
|
|
|
 |
hitwalker

|
Posted:
Wed Nov 10, 2004 8:27 pm |
|
well what should i change ? |
|
|
|
 |
hitwalker

|
Posted:
Wed Nov 10, 2004 9:05 pm |
|
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

|
Posted:
Wed Nov 10, 2004 9:12 pm |
|
ID needs to be set up as an auto_increment field. Then the system will handle it. |
|
|
|
 |
hitwalker

|
Posted:
Wed Nov 10, 2004 9:20 pm |
|
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.....
anyway thanks....im off to bed....... |
|
|
|
 |
chatserv
Member Emeritus

Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico
|
Posted:
Thu Nov 11, 2004 7:03 am |
|
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());
}
?>
|
|
|
|
|
 |
hitwalker

|
Posted:
Thu Nov 11, 2004 7:07 am |
|
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..  |
|
|
|
 |
chatserv

|
Posted:
Thu Nov 11, 2004 8:32 am |
|
Maybe you should post the code you are using for the search. |
|
|
|
 |
hitwalker

|
Posted:
Thu Nov 11, 2004 8:34 am |
|
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 ?  |
|
|
|
 |
chatserv

|
Posted:
Thu Nov 11, 2004 8:51 am |
|
Oh, thought you had something because you said that when you search it shows no results found |
|
|
|
 |
hitwalker

|
Posted:
Thu Nov 11, 2004 8:56 am |
|
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....  |
|
|
|
 |
chatserv

|
Posted:
Thu Nov 11, 2004 9:20 am |
|
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&file=search&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++;
}
|
|
|
|
|
 |
|