473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem reading data out of MySQL db, PHP variables

Below is part of a code I have for a database. While the database table is
created correctly (if it doesn't exist), and data is input correctly into
the database when executed, I have a problem when reading out the data into
the PHP variables / array.

It should be displaying the information out in the following way, using
the PHP array:

n_date, n_headline, n_summarytext, n_fulltext

But what actually gets displayed is the data for:

n_date, n_headline, n_summarytext

So the "n_fulltext" is not displayed, but the echo'ed text preceeding it
"Full text:" is displayed, but it is not reading the information out of the
variable. I have checked that there is information input in this field in
the db, and it is there.

A fresh pair of eyes looking over the code is appreciated.



// loop through result to look for your table
if (mysql_tablename($AllTableList, $connection)!=$TableName)
// Add data to create the fields needed in the guestbook
mysql_query("CREATE TABLE $TableName(
n_headline VARCHAR(60) NOT NULL,
n_summarytext VARCHAR(200) NOT NULL,
n_fulltext BLOB NOT NULL)");

// Enter the data into the guestbook database
// Note, the now() id is infact a MySQL date array type
$sql = ("INSERT INTO $TableName(n_date, n_headline, n_summarytext,
n_fulltext) VALUES(now(), '$_POST[headline]', '$_POST[summarytext]',

$result = @mysql_query($sql, $connection) or die("<B>Problem entering data
into database: </B>".mysql_error());

// Now read the information back out from the Database ready for printing
on screen
$sql = ("SELECT * FROM $TableName ORDER BY n_date DESC");

$readout = @mysql_query($sql, $connection) or die("<B>Problem reading data
from database: </B>".mysql_error());

// Build result array
$NewsItem = mysql_fetch_row($readout);
// Get the data from the result of the array positions and display them
$InputDate = $NewsItem[0];
echo "Submitted on: $InputDate<BR>";
$InputHeadline = $NewsItem[1];
echo "Headline: $InputHeadline<BR>";
$InputSummary = $NewsItem[2];
echo "Summary: $InputSummary<BR>";
$InputFulltext = $NewsItem[3];
echo "Full text: $InputFullText";
Jul 17 '05 #1
2 3004
ng@lycaus.plusYOURSHIT.com (Dariusz) wrote:
Below is part of a code I have for a database. While the database
table is created correctly (if it doesn't exist), and data is input
correctly into the database when executed, I have a problem when
reading out the data into the PHP variables / array. $InputFulltext = $NewsItem[3];
echo "Full text: $InputFullText";

$InputFulltext != $InputFullText

Jul 17 '05 #2
In article <Xn**************************@>, Jon Kraft <jo*@jonux.co.uk> wrote:
$InputFulltext = $NewsItem[3];
echo "Full text: $InputFullText";

$InputFulltext != $InputFullText

You see, that's been driving me mad for two days - I failed to spot that
mistake. Thanks for that Jon :) . All works okay now.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: dohnut | last post by:
Here's one for some bored problem solver :) I ran across this earlier today and fixed it, but don't exactly know why. (that usually only happens in C :) I'm using Perl version 5.8.0 btw. ...
by: I.P. | last post by:
------=_NextPart_000_03FF_01C368A4.75720DC0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Hi, it's my story. I have two 4.0.14 mysql server on...
by: Gary Cote | last post by:
>Description: I've recently compiled mysql 4.0.14 on redhat 8.0. The installation fails, however, when running mysql_install_db. I've attached a transcript below. I gather from searching the...
by: Boris Wilhelms | last post by:
Hello all, at first, sorry for my bad English, I’ll give my best  We have a strange problem reading Text- and VarChar-Fields. Our configuration: -Windows 2003 Server -MySQL Server 3.23.36...
by: Kevin D. | last post by:
Please note, I already posted this on the MySQL official forum, but received no response. I thought I'd try again in another location. My apologies to anyone reading this twice... Despite...
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction:...
by: Einstein30000 | last post by:
Hi, in one of my php-scripts is the following query (with an already open db-connection): $q = "INSERT INTO main (name, img, descr, from, size, format, cat, host, link, date) VALUES ('$name',...
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.