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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-25-2005, 03:37 PM
|
#1
|
Member
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115
Rep:
|
php, mysql error
My database is just a single table with no relations:
create database texter;
create table (titel varchar(255),datum date,text longtext)
I'm getting an error on line 44 wich is around here:
// im using mysql_fetch_array(). il precise a bit
while($row = mysql_fetch_array($result))
{
$texter = $row['titel'];
printf("%s, %s<br />", $texter);
Il admit i dont really know how to insert my database into the php code
I would really appreciate if someone could look at my database structure and just fill in whats missing
Thanks!
|
|
|
04-25-2005, 04:33 PM
|
#2
|
Moderator
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696
|
Well..
Code:
printf("%s, %s<br />", $texter);
Two %s, one parameter with value. If I remember correctly it won't use the same for both %s.
|
|
|
04-25-2005, 05:25 PM
|
#3
|
Member
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115
Original Poster
Rep:
|
Okay thanks! that worked 
edit: once i tested to add something and it didnt work, i removed it and nothing works instead....
But how do i get it to spit out the text and not just the title?
// im using mysql_fetch_array(). il precise a bit
while($row = mysql_fetch_array($result))
{
$texter = $row['titel'];
printf("%s, %s<br />", $texter);
it didnt work to add :
$texter - $row['text']
and another %s
then it just skips everything and goes to else wich is "no posts found"
Last edited by Alexander.s; 04-25-2005 at 05:37 PM.
|
|
|
04-25-2005, 09:33 PM
|
#4
|
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821
Rep: 
|
Code:
$query = mysql_query( "select name, title from user where name = $user ")
while ( list ( $name, $title ) = mysql_fetch_row( $query ))
{
// do whatever with $name and $title for this row
}
The number of items in the list() call must match the number of items in the select.
|
|
|
04-26-2005, 10:00 AM
|
#5
|
Member
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115
Original Poster
Rep:
|
Okay i rearranged my database instead made 2 tables and now it works.
now its just design how do i get title first and the text under it?
like:
(Title) Diablo
(Text) ince the beginning of time, the forces of Order and Chaos have been engaged in an eternal struggle to decide the fate of all Creation. That struggle has now come to the Mortal Realm...and neither Man, Demon, nor Angel will be left unscathed...
And it would be nice to get the text more centered or in a box. its pretty hard to read it like that.
thanks!
|
|
|
04-26-2005, 04:28 PM
|
#6
|
Moderator
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696
|
Well...write HTML code that should be filled and then just fill it. I don't understand where's the problem. Example:
printf("%s <br />%s<br />", $titel, $longtext);
|
|
|
04-26-2005, 04:51 PM
|
#7
|
Member
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115
Original Poster
Rep:
|
there is no problem since you showed me where to put the html code, cuse where i put it i just got errors, wich was 1 cm to the right of where you put it
thanks
|
|
|
All times are GMT -5. The time now is 01:46 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|