forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Could it be that I have the code for the db copied 4 more times on the same page? And yes it is: Is userid in your db table `members`? If so it must be exactly as it is in the table. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 Could you please post your current code? Don't need database details as long as you are sure it is connecting. Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Yup im sure and I realize that Im probably not meant to connect to the database 5 times =) <?php require('require.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Designer Vision - Adventure Plan</title> <style type="text/css"> <!-- ul{ list-style-image:url(file:///C|/Documents and Settings/Owner/My Documents/Sam/samweb/../images/../images/arrow2.jpg); } .style4 {font-size: 18px; color: #3A3A3A; font-weight: bold; } .style6 {font-size: 12px; color: #3A3A3A; text-decoration: none; } .style11 {font-size: 22px; color: #5B5E71; font-weight: bold; } .style13 {font-size: 14px; color: #3A3A3A; text-decoration: none; font-weight: bold; } .style14 {color: #3A3A3A; text-decoration: none; font-size: 14px;} .style17 {color: #333333} .style19 {color: #000000} .style20 {color: #5B5E71} .style1 { font-size: 16px; color: #3A3A3A; text-decoration:none; } .style21 {font-size: 16px; color: #3A3A3A; font-weight: bold; } .style66 {font-size: 14px; color: #3A3A3A; text-decoration:underline; font-weight:bold; } .style57 {font-size: 12px; color: #3A3A3A; text-decoration: underline; } ul{ list-style-image:url(../images/arrow2.jpg); } .style69 {font-size: 14px; color: #FF0000; font-weight: bold; } --> </style> </head> <body background="bg.gif"> <table width="100%" border="0" align="center"> <tr> <td height="24"> </td> </tr> <tr> <td><table width="760" height="885" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="760" height="240" background="../images/webtop.gif"><table width="100%" height="240 " border="0" cellpadding="0" cellspacing="0"> <tr> <td width="760" height="240"><table width="94%" height="207" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="53"> </td> </tr> <tr> <td height="127"> </td> </tr> <tr> <td height="20" class="style13"><div align="right" class="style14"><a href="index.php" class="style14">home</a> <a href="services.php" class="style14">services</a> <a href="portfolio.php" class="style14">portfolio</a> <a href="plans.php" class="style14">plans</a> <a href="contact.php" class="style14">contact</a> </div></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="605" background="../images/webrep.gif"><table width="96%" height="605" border="0"> <tr> <td width="3%" height="400" rowspan="3"> </td> <td width="22%" rowspan="3" align="center" valign="top" class="style4"><?php include("../menu.php"); ?></td> <td width="4%" rowspan="3"> </td> <td height="544" valign="top" class="style13"><table width="100%" border="0"> <tr> <td><div align="right"> <?php include("log.php") ?> </div></td> </tr> </table> <p>Here is the progress of your site. </p> <p>Please note that this will be updated daily or whenever more work for your site is completed. </p> <table width="100%" border="0"> <tr> <td><?php $database=mysql_connect("localhost","***","**"); mysql_select_db("test",$database); //echo $userid; $query="select * from members WHERE userid=$userid"; $result = mysql_query($query) or die(mysql_error()); while($img=mysql_fetch_assoc($result)){ $image_num=$img['stg1']; if($image_num=="0"){ echo"<img src='images/not_completed.gif' />"; }elseif($image_num=="1"){ echo"<img src='images/completed.gif' />"; }else { echo" sorry there is no images to show"; } } ?></td> </tr> <tr> <td> /*<?php $database=mysql_connect("localhost","***","**"); mysql_select_db("test",$database); //echo $userid; $query="select * from members WHERE userid=$userid"; $result = mysql_query($query) or die(mysql_error()); while($img=mysql_fetch_assoc($result)){ $image_num=$img['stg2']; if($image_num=="0"){ echo"<img src='images/not_completed.gif' />"; }elseif($image_num=="1"){ echo"<img src='images/completed.gif' />"; }else { echo" sorry there is no images to show"; } } ?></td> </tr> <tr> <td><?php $database=mysql_connect("localhost","***","**"); mysql_select_db("test",$database); //echo $userid; $query="select * from members WHERE userid=$userid"; $result = mysql_query($query) or die(mysql_error()); while($img=mysql_fetch_assoc($result)){ $image_num=$img['stg3']; if($image_num=="0"){ echo"<img src='images/not_completed.gif' />"; }elseif($image_num=="1"){ echo"<img src='images/completed.gif' />"; }else { echo" sorry there is no images to show"; } } ?></td> </tr> <tr> <td><?php $database=mysql_connect("localhost","***","**"); mysql_select_db("test",$database); //echo $userid; $query="select * from members WHERE userid=$userid"; $result = mysql_query($query) or die(mysql_error()); while($img=mysql_fetch_assoc($result)){ $image_num=$img['stg4']; if($image_num=="0"){ echo"<img src='images/not_completed.gif' />"; }elseif($image_num=="1"){ echo"<img src='images/completed.gif' />"; }else { echo" sorry there is no images to show"; } } ?></td> </tr> <tr> <td><?php $database=mysql_connect("localhost","***","**"); mysql_select_db("test",$database); //echo $userid; $query="select * from members WHERE userid=$userid"; $result = mysql_query($query) or die(mysql_error()); while($img=mysql_fetch_assoc($result)){ $image_num=$img['stg5']; if($image_num=="0"){ echo"<img src='images/not_completed.gif' />"; }elseif($image_num=="1"){ echo"<img src='images/completed.gif' />"; }else { echo" sorry there is no images to show"; } } ?>*/</td> </tr> </table> <p> </p></td> </tr> <tr> <td valign="top"><div align="center"><a href="contact.php" class="style66">Contact Us</a></div></td> </tr> <tr> <td> </td> </tr> </table></td> </tr> <tr> <td width="760" height="40" background="../images/webbot.gif"> </td> </tr> </table></td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 ya close all mysql connections mysql_close ($database); Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 As long as all your queries are from the same db you only need to connect and select db once. In addition you have this for every query: $query="select * from members WHERE userid=$userid"; This is telling it to select nothing from the db. Should be something like select img or something. You need to tell the db what you want selected from it. In your table there is a field that you want brought to the page. What is it? Quote Link to comment Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 star means select everything Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 Wow did not know that. He He very green yet. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 At the end of your queries you don't have single quotes around $userid like this '$userid' Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 17, 2007 Share Posted February 17, 2007 The "select *" selects all fields. Ken Quote Link to comment Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 ya '$userid' would maybe change something but it could still work without them if its only numbers after all if it has a space after the number lets say $userid= " 3"; that would give a error and you have to use quotes than but well I guess he solved it Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Nope still not solved. I dont know what to do. What did you mean by this? ya close all mysql connections mysql_close ($database); Quote Link to comment Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 you open 5 db connections but you never close em Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Nothings working Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 I can't seem to find where you defined your variable $userid $userid=??? Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Isnt is in this part? $query="select * from members WHERE userid=$userid"; Anyway, I have simplified it. Here is it: <?php require('require.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $database=mysql_connect("localhost", "aaaa", "aaaaa"); mysql_select_db("test",$database); echo $userid; $query="select * from members WHERE userid=$userid"; $result = mysql_query($query) or die(mysql_error()); while($img=mysql_fetch_assoc($result)){ $image_num=$img['stg1']; if($image_num=="0"){ echo"<img src='images/not_completed.gif' />"; }elseif($image_num=="1"){ echo"<img src='images/completed.gif' />"; }else { echo"sorry there is no images to show"; } } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 whats not working? you add that mysql_close($database); at the end of everything when you are done with database Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 It still isn't defined. What does $userid stand for? $_POST['userid'], $_SESSION['userid'] Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 sspoke - yes i just added it and it still says You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Greaser9780 - $_SESSION['userid'] Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 In your queries did you try putting single quotes around $userid at the end of your query?If not try it once. Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Ok, i just tried it - it came up with a blank screen. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 What is $userid equal to? Other than your query statement. It must be defined before that. Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 the database row name is userid is this right? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 It also needs to be identified in the php. The query uses userid from php to relate to your table. Usually it is defined as a post userid or a session userid. Somewhere in the code before the query it should have $userid= then after the equal sign you define what exactly it is. What I am trying to say is, how does this php file identify with $userid? POST from a form, a session, or does it need passed on from the previous web page? Quote Link to comment Share on other sites More sharing options...
forumnz Posted February 17, 2007 Author Share Posted February 17, 2007 Right, so, userid is the primary key in the db and when the user is logged in it should set the cookie with the userid (makes sense?). What would I need to put after the = in $userid=? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 So you used a cookie to set the user id? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.