FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Why am I getting values of 0 and 5?





ProwerBot
I have this php code for a home page:

Code:
case "home":
$sql = "SELECT * FROM news ORDER BY id DESC";
if (!$result = mysql_query($sql)) die(mysql_error());
while($rows = mysql_fetch_array($result)){
 echo ("<b>" . $rows['newstitle'] ."</b><br />
<i>Posted by <b>" .$rows['newsauthor']. "</b> on " .$rows['newsdate']. ".</i><p />
" . $rows['newspost'] . " <br /><hr /><p />");
}
break;


and just for testing purpouses I have this thing
Code:
case "testnews":
mysql_query("INSERT INTO news (newstitle, newsauthor, newspost)
VALUES ('Welcome', 'Jason', 'This website is under construction at this time. Check back soon.')");
break;

But whenever I run that all it puts in the database is zeros. I'm guessing some of the settings are off? I'm reusing a forum script I wrote back in 2008 (I have it posted on here because I had a different account) and I had it working pretty good back then but it just refuses to work now. Why, I have no idea. I'm guessing I didn't create the tables on the database right?
Peterssidan
zeros? are you sure you store fields as a text type and not as numbers?
When you insert one row, is a new row created in the table?
ProwerBot
Peterssidan wrote:
zeros? are you sure you store fields as a text type and not as numbers?
When you insert one row, is a new row created in the table?

Yes a new row is created but newstitle, etc. are just zeros.
Peterssidan
And what data type are you using for newstitle, newsauthor and newspost?
ProwerBot
Ok good. I finally figured it out... it was set to an integer value and not text :p. It's been a while since I've been doing much with PHP (6th grade, I think..I'm in 9th now) so I forgot a lot of this stuff.
Related topics
Decimal, Binary and Hexadecimal
30 Gigs invites for just 0.5 frih$
[OFFICIAL] World Of Warcraft - No new topics about this
Need help securing wireless network
Why is it that everything I do does not work!
Changements to the Points/frih$ system (Discuss)
Visual Basic Tutorial - Random numbers
Triple suicide at Guantanamo Bay
Anything is POSSIBLE!
Math Problem
forum fireboard sur joomla 1.5
What is the usefulness of religion?
Homework problem
It's getting huge! 0.o
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.