LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2005, 07:43 AM   #1
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Rep: Reputation: 15
Backend problem in bash!!


Currently using:
MySQL
Bash
Apache

Im creating a script wich is intented for my website. It records what your typing
and throws it out on your screen, if it exists.

My humble question is what have i done wrong?
The "else" and "fi" commands are marked red thats Vim's way saying iv done wrong
but i dont know exactly what i have done wrong?

Thanks!

edit: The script still wont do anything, when i search for something nothing happens


Regards / Alexander / Sweden




------------------------------------------------------------------------------------------------------
#!/bin/bash/


TITEL=$(echo $QUERY_STRING | cut -d\& -f1 | cut -d= -f2)
DATUM=$(echo $QUERY_STRING | cut -d\& -f2 | cut -d= -f2)
TEXT=$(echo $QUERY_STRING | cut -d\& -f3 | cut -d= -f2)
KOLL=$(echo "SELECT count(titel) FROM TEXTER WHERE titel='$TEXTER';"| mysql -N -u root TEXTER)

#skriv en HTTP-Header
echo "content-type: text/html"
echo

#Skriv en HTML-Header
echo "<HTML><HEAD><TITLE>Resultat</TITLE></HEAD><BODY>

if [ $KOLL -ne 0 ]; then
echo "<h4 style=\"color: #fff\">Titeln $TITEL finns redan!.</h4>"

else

echo "INSERT INTO TEXTER(titel,datum,text) VALUES ('$TEXTER','$DATUM','$TEXT');"| mysql -u root -N TEXTER
echo "Titeln till texten är tillagd"
fi

echo "SELECT titel FROM TEXTER;" | mysql -N -u root TEXTER > /tmp/sqlsvar
IFS=$'\n'
echo "<P>Dessa Titlar finns i tabellen</P>"
echo "<ul>"
for i in $(cat /tmp/sqlsvar); do
echo "<li>$i</li>"
done
echo "</ul>"

# skriv HTML-slutet
echo "</body></html>
-----------------------------------------------------------------------------------------------------

Last edited by Alexander.s; 04-11-2005 at 09:18 AM.
 
Old 04-11-2005, 07:57 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
vim is not the arbiter of correctness.
it's an editor,

If the script runs OK then vim is wrong.
It's only doing syntax highlighting.
 
Old 04-11-2005, 09:17 AM   #3
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Original Poster
Rep: Reputation: 15
Iv corrected the syntax but the script still wont work
 
Old 04-11-2005, 09:56 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
what does it say in your apache error log
when you access the page?

(have you considered using perl CGI?)
 
Old 04-11-2005, 04:47 PM   #5
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Original Poster
Rep: Reputation: 15
i only know bash

Did you get what im after here on my webpage? i want to search in my database and make the results
end up in the webbrowser.

Could you guys give me a hint on what i should do?
maybe show me a script in perl that can do what im trying to do in bash?

My first script is for inserting data into the database and this one was supposed to take it out.


Thanks!


Regards / Alexander / Sweden
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change totem backend TruongAn Linux - Software 2 08-19-2005 05:40 AM
problem with adding backend hpreet.singh Linux - Software 2 04-26-2005 12:33 PM
LDAP PostgreSQL Backend PrimusXPrimus Linux - Security 2 04-18-2004 07:20 AM
9.1 CUPS backend missing davidsrsb Slackware 1 10-16-2003 08:53 PM
Backend -Frontend Interaction unbeknown Linux - Software 1 07-29-2003 03:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration