SQL -- getting one row problem

Good afternoon,

Here is the output of my script, and can’t understand why this is not working.
Thanks for any and all pointers!
Dave Gilden

someone@monsoon:~/cgi-bin$  mail_guest_to_jk.cgi 
Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 33.

Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 37.
DBD::mysql::st execute failed: You have an error in your SQL syntax near '' at line 1 at ./mail_guest_to_jk.cgi line 60.
DBD::mysql::st fetchrow failed: fetch() without execute() at ./mail_guest_to_jk.cgi line 40.
Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 41.
Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 41.
Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 41.
Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 41.
Use of uninitialized value in concatenation (.) or string at ./mail_guest_to_jk.cgi line 41.



the script:
---------------------
#!/usr/bin/perl -w

use DBI;
use strict;

## Sensitive stuff deleted :)

my ($sql,$dbh,$sth,$datecreated,$name,$email,$comments);

&initialize_dbi;


#### Read from Guestbook ###################

### get id for last entry  
$sql ="SELECT MAX(id) FROM $table_name;";

run_statement($sql);

my $id = $sth->{id};
print "$id\n";

$sth->finish; 

$sql = "SELECT id, DATE_FORMAT(DATE_ADD(datecreated, INTERVAL 2 HOUR), '%c/%e/%y at: %l:%i %p'),email, name, comments FROM $table_name where id = $id;";

run_statement($sql);
# get the one row selected
($id,$datecreated,$email,$name,$comments) = $sth->fetchrow;
print "$id\n$datecreated\n$email\n$name\n$comments";
$dbh->disconnect; # close date base connection 
exit;


sub initialize_dbi{
   my $drh = DBI->install_driver( 'mysql' );
   $dbh = DBI->connect("DBI:mysql:$user_name:$sql_server", $user_name, $user_password);
   die "Cannot connect: $DBI::errstr\n" unless $ ;
}


sub run_statement{
    my $stmt = shift;
    $sth = $dbh->prepare($stmt);
    $sth->execute;
}

__END__




==============================================
         Cora Connection: Your West African Music Source
              Resources, Recordings, Instruments & More!
                   <http://www.coraconnection.com/> 
==============================================
0
dowda
9/29/2003 9:11:58 PM
perl.beginners.cgi 3839 articles. 0 followers. Follow

0 Replies
399 Views

Similar Articles

[PageSpeed] 33

Reply:

Similar Artilces:

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

Problem with updating only one row in a SQL 2005 database
hi, I have a problem with updating a row in my database. I don't know how to update and i need help. I have a form where the users select a category and a sub category to enter a message. I have two dropdown lists, one is for selecting the category and the other is for the sub-category. In my database for the categories and the sub-categories, i have a variable (Quantity) where i keep the quantity for each table. I just want to be able to increment this variable by 1 (for the selected category and sub-category) when a user enter a new message... The insert procedure is working well and...

Return value for one selected row from a SQL database/Dataset problem
I try to get a value from ArtikkelId from a SQL database into a textbox. Can anyone help me? My Code----------------------------------------- Imports System.DataImports System.Data.SqlClient Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Conn_News_db As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("NEWS_CS1").ToString()Dim SQL_conn As New SqlConnection(Conn_News_db)Dim SQL_cmd1 As New SqlCommand()Dim myDataSet As New DataSetDim Select_ArtId_Max As String = "Select ArtikkelId from Hoved where A...

SQL Problem
 I am having a problem when uploading image data into SQL... The following statement correctly inserts the data into the SQL database: (database connection declaration...)         commInsertImage = New SqlCommand( _        "INSERT INTO [Images] ([Title], [MIMEType], [ImageData]) VALUES (@Title, @MIMEType, @ImageData) " & _        "SELECT SCOPE_IDENTITY() As ImageID", conn)(...Varible declarations...)        conn.Open()  ...

How to read a dataset one row by one row?
I know you can use DataSet after close sql connection. I want to something after getting dataset, read from one row by one row, just like while datareader.read() Can I read dataset just like this? Thanks in advance! Justin Is this what you're looking for (from the Tips and Tricks Section of ASPNet101.com):http://aspnet101.com/aspnet101/tips.aspx?id=175David WierMCP/ASPInsiderASPNet101.com - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as Answer&...

SQL beginners problem !
*** edited by: master4eva *** Please enclose your code in < code ></ code> tags (without the spaces). This will make your code easier to read online; therefore, encouraging a response to be faster. It is to your own benefit for your question to be answered in future. I have already done the editing to include the < code ></ code> tags for this post. ********* Hi, I am following tutorials in a book to try and implememnt a basic select query using SQL. However i am following all the instructions, which includes entering this header: <%@ Page La...

2 gridviews on one row, problem with render for double click function on a grdiview row
Hi, I have an application with 2 gridviews on one page. On the first gridview (GridViewRequests) I have a function to double click on a row, when I double click a detail screen opens where I can edit the data of the selected row. Now I want the samen function on my second gridview (GridView1). I was thinking this should go easy because I can simply copy the code from the first function en change the names to my second gridview. But I have a piece of code which I can't duplicate. Can I solve this in another way?? It's this code: Protected Overrides Sub Render(ByVal writer As HtmlTex...

is it possible to turn 1 column,many rows into one row,many columns in sql ?
 Hi AllI have the following query:Select CategoryName From Category Where CategoryId In(Select SkillId From SpecialitySkills Where CopywriterId = 13) It gives me the correct results but not in the form that i want, i would like it to be in one row, many columns. its in 1 column, many rows.Any ideas?  You must be talking about displaying it on a web page? Just create a loop that runs through the rows of the data that is returned then just make html table:dim tablestring as string = "<table><tr>" for i as integer = 0 to dt.rows.count - 1 tablestring += &...

Sql problem one more time
I used: select d.name from sysdevices d, sysusages u where u.vstart between d.low and d.high and u.dbid = db_id("mat") go and it works and I've got a name of the device (or devices) but i need one more thing: I want to know on what device is data and on what device is log (if a database have logs and data on separate devices) Please help me one more time Thanks a lot Mat - mfinch@o2.pl select segmap from sysusages. a segmap of 3 is data and a segmap of 4 is log. If you have user defined segments for a particular database you will see other values for s...

One SQL db allowed problem
Hi I'm just about to deploy my website.  I've signed up to a web host that allows me 1 SQL server db. However, i've just realized that in order to provide login etc, VS has added another SQL db - 'ASPNETDB.MDF'.  So, I now have 2 databases but my ISP only allows me to host one.  Is it OK for me to add my 'Customer' database tables to the 'ASPNETDB.MDF' to solve this problem? Thanks! You can merge your two databases together. Actually, I would create all objects of ASPNETDB in my database to start.Limno Do you mean that I should...

Inserting Multiple Rows in One SQL
Hi, would like to know if there are any links or sample code to learn how to Insert multiple rows with 1 sql statement.Also, can the inserted values' source be from a table in another database table or from a dataset?I am actually trying to insert about 117 rows of data.Table 1======UID               Primary Key TeamCode      a code value representing different teams Week              will equal to 2Points  &n...

SQL database rows count problem..
i  am using Sql Server database and i am trying to count the total rows... but it always say 0 rows please help me i have this on my page load: Dim objProduct As New Product gvproduct.DataSource = objCat.GetProducts() gvproduct.DataBind() lblrows.Text = objProduct.rowscount     i have this on my class file Product.vb Public rowscount as integer Public Function GetProducts() As DataSet Dim strConn As StringstrConn = ConfigurationManager.ConnectionStrings("StellarBookstoreConnectionString").ToString Dim conn As New SqlConnection(strConn) ' Retrieve p...

how to drag and drop one row from one datawindow and update the exist row in other datawindow ?
I liked to drag and drop a field (assume: name) from a row of one datawindow (dw_1) to another datawindow (dw_2), and also update the exist row in dw_2. Thanks for help. -- Best regards, Ridwan Goldbase Technology Visit our Homepage : http://www.geocities.com/Wallstreet/Floor/5251/index.html http://members.tripod.com/goldbase http://members.xoom.com/goldbase * Check out the Y2K (Year 2000 Problems - Millenium Bugs) Take a look at the Drag Drop entries in the help file. Basically, you need to turn on Dragging using Drag(Begin!). When you drop onto dw_2, the drag...

Reduce rows displayed but putting 3 rows in one row
Hi all, I'm using PB6.5. I have an SQL DW that fetch some information from the DB but should display only two columns: a code and a value. Also they are displayed in the trailer of a group if that's actually important. In order to reduce displayed rows count, i would like to display each 3 rows in one row(Code,Value,Code,Value,Code,Value). The question is how can i do that?. I've tried to use computed fields and in the second and third pair values to use code[1],value[1],code[2],value[2] but only the code[1],value[1] are OK(Showing next row's data), the third ...

selecting one row and inserting it into another table one by one
i ve a table named "Employee" in wh i ve fields "Emp_Id","Name" and "Email". i want to select each employee "Emp_Id" one by one from "Employee" table and insert it into another table named "Concerned_Department". like if i ve three rows in "Employee" table with "Emp_Id" 1,2 and 3 respectively,in this case i want to first select "Emp_Id"=1 then "Emp_id"=2 and lastly "Emp_id"=3 and insert them into "Concerned_Department"table.  after that the process star...

Web resources about - SQL -- getting one row problem - perl.beginners.cgi

The only candidate not playing into ISIS hysteria is Bernie Sanders, and he's surging in the polls
U.S. Presidential candidate Donald Trump continues to grab all the media attention, and Hillary Clinton remains a Wall Street favoriteso why ...

Suicide bomber killed in raid after Paris attacks identified
The Paris prosecutor has identified a suicide bomber killed during a police raid focused on the suspected ringleader of the November attacks ...

Rene Angelil, Celine Dion’s Husband and Longtime Manager, Dies at 73
Rene Angelil, the husband and former manager of Celine Dion, died of throat cancer on Thursday at his Las Vegas home, Dion announced on her Facebook ...

Three Winning Powerball Tickets Sold, Winners Will Share the $1.6 Billion Prize
Three winning tickets were sold for the $1.6 billion Powerball jackpot and the winnings will be divided between the lucky individuals! The tickets ...

VIDEO: Drones break Guinness world record
BBC Click's LJ Rich looks at some of the best of the week's technology news

Here’s what automakers think of Obama’s autonomous car plans
The auto and electronics industries alike have reacted positively to the DoT's news of a near-$4bn push for autonomous vehicles. The decade-long ...

First iOS 9.3 Beta Released To The Public
Over the past week, we have been hearing a lot about iOS 9.3 and what kind of features it will be bringing to the table. The good news is that ...

Skype makes it easy to start work calls in Slack
If you think the one thing Slack is missing is the ability to start voice/video calls, you're in luck. Skype released a preview version of its ...

Amazon Prime Membership Discounted By 20% This Weekend
Recently Amazon announced that their Prime subscribers will be getting a permanent 20% discount in the future if they were to pre-order games ...

Chicago Releases Three Videos of Black Teenager's Police Shooting Death
On Thursday, videos of the fatal police shooting of Cedrick Chatman, a black teenager, by a white Chicago police officer in January 2013 were ...

Resources last updated: 1/15/2016 1:44:48 AM