Jump to content

Im just getting back into PHPing...


V-Man

Recommended Posts

Hey guys, It's been ages!

 

Alright, Im just now getting back into PHPing and have found my self in a slump.  Here's what I want to do.

 

Select all the rows out of a table (this will be five, as all others will be deleted) and display them with the text and the user that posted it.  Im coding a shout box for my guild website.

 

Heres what I have so far.  And yes, my session based login works already and the variables pass correctly.

 

the SQL table that i set up

CREATE TABLE `shout` (
  `id` mediumint( unsigned NOT NULL default '0',
  `text` varchar(40) NOT NULL default '',
  `user` varchar(32) NOT NULL default '',
  `shown` int(1) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

Now, I know what I need to do:

select the rows, display them like so:

 

 

 

"blah blah blah blah",

--{the username}

 

"blah blah blah blah",

--{the username}

 

 

 

 

That's what I need to do.  But I can't for the life of my remember how to do it.  Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/38095-im-just-getting-back-into-phping/
Share on other sites

yes, I updated my DB.  The error im getting is

 

ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'query' at line 1

 

 

 

 

NOT the unidentifyed row error.

$query = "INSERT INTO shout (`text`,`user`,`shown`) VALUES ('".$post."','".$user."',CURRENT_TIMESTAMP)";

 

Only other problem I can see is that you're trying to insert a TIMESTAMP variable into an INT container sized 1 - meaning it can only store a single number (0-9). Try changing the datatype of "shown" to DATETIME. You could also use INT size 10 UNSIGNED and use this instead:

$query = "INSERT INTO shout (`text`,`user`,`shown`) VALUES ('".$post."','".$user."','".time()."')";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.