Webmaster Forum
Go Back   Webmaster Forums UK SEO SEM Webmaster Community Forum - UKWW > General > General Webmaster Talk
Register FAQ Members List Downloads Calendar Today's Posts Webmaster Resources Webmaster Blogs

UK Web Hosting
UK Web Hosting
Website Hosting
Website Hosting
UK One Way
UK One Way
Get Top 10 Exposure
 
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-21-2007, 02:58 PM
Junior Member
 
Join Date: Aug 2007
Posts: 6
iTrader: 0 / 0%
StevieB is on a distinguished road
Default problem with Sessions

I'm trying to output sessions "row 0" "row 1" etc and all I get is either a blank output or "Array"

This was working before I put the loop in.
I think there's a problem with ['row '.$i]
I've tried
$row = "row ";
$row = $row.$i - but that doesn't work either.

Can anyone see where i'm going wrong?


The php is -

$query = " SELECT * FROM table ORDER BY RAND() LIMIT 1 ";
for($i = 0; $i <= 2; $i++)
{
if($result = mysql_query($query))
{
while( $output = mysql_fetch_row($result) )
{
// create name and output to session
$_SESSION ['row '.$i] = $output;
}
mysql_free_result($result);
}
}


the output page is

echo $_SESSION['row 0'];
echo ' <br>';
echo $_SESSION['row 1'];
echo ' <br>';
echo $_SESSION['row 2'];
echo ' <br>';

I can't think of any other way of creating row 0, row 1 in the loop.

Thanks in advance.
Steve.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 09-21-2007, 03:21 PM
Boss Cart Support
 
Join Date: Apr 2007
Posts: 3
iTrader: 0 / 0%
clau is on a distinguished road
Default

Hi Steve,

You get an array at the output page because the $output variable is an array of the columns you have in the table.
If you want to use a certain column you need to use either $output[column-name] or better, in the output page put
$row0 = $_SESSION['row 0'];
echo $row0[column-name1].' '.$row0[column-name2].....

Claudiu
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 09-21-2007, 04:35 PM
Junior Member
 
Join Date: Aug 2007
Posts: 6
iTrader: 0 / 0%
StevieB is on a distinguished road
Default

Ah yes, of course, I mised that.
Cheers mate, spent ages trying to suss it out.

have changed the processing page to ~

for($i = 0; $i <= 2; $i++)
{
if($result = mysql_query($query))
{
while( $row = mysql_fetch_row($result) )
{
$output = $row[$i];
$_SESSION ['row '.$i] = $output;
}
// free results
mysql_free_result($result);
}
}




Works now.

Thanks again.

Steve
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
Reply

Bookmarks

Webmaster Resources
UK Web Hosting
UK WW SEO Tools
Free site submission
Web Directory
 
Advertisement
firewall script
 
Site Of the Month
BizzFace
Nominate site of the month
 
Tag Cloud
3.7 adsense ads space bollywood downloads bollywood latest buy banners cctv changing host changing server channel solutions cheap off page packages cheap seo packages cheap seo services closing coupon code boss cart jv directory announcement domain name extension domain names e brochures ecommerce flash website promotion flash websites forum free directory free directory software google google adwords hostquack host quack inline price changes introduction ipn paypal payment boss job site joomla job junglejar junglejar.com lbs. link bid script link bid script hungarian link exchange linux host moving server nokia off page seo packages picture of the day referral sale sell baners seo seo packages shared hosting sososher submit url switching host symbian templates tld today in history traffic transfering host uk shipping postcodes upgrade vbulletin web design webinare webmaster tools website wordpress

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
If you ever had this problem... darkstar_tfd General Webmaster Talk 8 11-06-2007 08:43 AM
problem with Sessions StevieB General Webmaster Talk 0 09-21-2007 02:57 PM
little problem Bisje Feedback (Don't holdback :) 6 09-20-2007 12:40 PM
Problem! smartu iG Shop 0 01-14-2004 05:41 AM
Problem Funnydummy iG Shop 0 11-04-2003 12:10 PM


All times are GMT. The time now is 06:18 AM.

UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons.
Subscribe to our feeds   Subscribe to our feeds

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149