Jump to content

Godoploid_Design

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Godoploid_Design's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks Gizmola, after looking at what you said I went through and rechecked my syntax. I moved all of the code from inline to a require file and somehow must have deleted the comma somehow thanks!!!
  2. I know this has to be something simple but I can not figure out for the life of me why this keeps happening. I have used these syntaxs many times before and never got this result. <?php $ifav = explode(","$ufav); foreach($ifav as& $f) { $cfavor = mysql_query("SELECT * FROM company WHERE cid = '$f'"); while($cfav = mysql_fetch_array($cfavor)) { $fcid = $cfav['cid']; $fcname = $cfav['cname']; $fcity = $cfav['city']; $fstate = $cfav['state']; $favorite .= '<p>' . $fcid . '. <a target="_blank" href="list.php?cid=' . $fcid . '">' . $fcname . '</a> ' . $fcity . ', ' . $fstate . '</p>'; } } ?> I have a column in a database where there are comma separated values. I wanted to take those values($ufav) and explode them into separate values where I could then take action on them. For this I ran an explode() then a foreach loop grabbing the exploded values where i queried the database multiple times in order to grab all of the information related to the comma separated values. From there I put the information into a variable and then echoed it out into the page where I required this entire value. Everytime I run this code I get this error: Parse error: syntax error, unexpected T_VARIABLE in /home/content/11/7370211/html/sites/searchapartmentsonline/development/includes/user/fav.php on line 3 Which is this line of code: $ifav = explode(","$ufav); This has to be simple and has driven absolutely nuts because I can't figure out for the life of me why this code is returning this error. If you could help I would greatly appreciate it! Thanks!
  3. Thank you so much, I thought there might be some kind of statement like this but I let the while idea that you can select everything via a column from another table. Thanks!!!!
  4. Ok so basically I have two tables the story which houses all story information plus the posting users id "uid" and then I have a table with user info. What I want is to run one query to show the story then grab the posting users information via the story tables posting user id column. That way whatever image or name they have on file will always update everytime the page is corrected. The only reason I didn't try a join is because I need to first get the uid (users id) that posted the story in order to select the proper user If this still doesn't make sense let me know!
  5. I have a site where I built two tables that house user information and their story information. The site is kind of like a blog in that people can post their own own stories about their relationships. Basically the story table has all the stories information like id, title, body etc and the posting persons id. The second table has the users info such as id first name, last name, etc. I have a story.php which is dynamic in that it grabs information based on the url so if there is story 2 the link would be story.php?sid=2. So what happens is the information is pulled based on that sid and in turn the posting users id is pulled via a while loop where i create variables for every column in the table. What I want is to be able to run basically two while loops on inside the other in order to get information based on the initial while loop column uid (users id). I don't know if this is clear but this is what I've build: function story() { // connection information include 'includes/connection.php'; $sid = "23"; // mysql connection mysql_connect("$host", "$user", "$pass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error()); // grabs all story information $squery = ("SELECT * FROM $stable WHERE sid = '$sid'"); $sresult = mysql_query($squery) or die(mysql_error()); $fullstory = ''; while($srow = mysql_fetch_array($sresult)){ // grab variables for the story $ssid = $srow['sid']; // stories id $title = $srow['title']; $body = $srow['body']; $keywords = $srow['keywords']; $suid = $srow['uid']; // the posting users id $sdate = $srow['date']; $accusedfname = $srow['accusedfname']; $accusedlname = $srow['accusedlname']; $location = $srow['location']; $accusedfacebook = $srow['accusedfacebook']; $accusedmyspace = $srow['accusedmyspace']; $accusedimage = $srow['accusedimage']; // mysql connection mysql_connect("$host", "$user", "$pass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error()); // grabs all information on the posting user $uquery = ("SELECT * FROM $utable WHERE uid = '$suid'"); $uresult = mysql_query($uquery) or die(mysql_error()); // grabs the posting users information while($urow = mysql_fetch_array($uresult)){ $uid = $urow['uid']; $fname = $urow['fname']; $lname = $urow['lname']; $image = $urow['image']; $fullstory .= ' <div id="story-wrap"> <div class="story-image"> <p> The Accused: '.$accusedfname.' '.$accusedlname.'<br/> <a target="_blank" href="'.$accusedimage.'"><img src="'.$accusedimage.'" alt="'.$accusedfname.' '.$accusedlname.'" title="'.$accusedfname.' '.$accusedlname.'" /></a> </p> <p> The Accuser: <a href="user-profile.php?uid='.$uid.'">'.$fname.' '.$lname.'</a><br/> <a target="_blank" href="'.$image.'"><img src="'.$image.'" alt="'.$fname.' '.$lname.'" title="'.$fname.' '.$lname.'" /></a> </p> </div> <div class="story-copy"> <h3><a href="user-profile.php?uid='.$uid.'">'.$fname.' '.$lname.'</a> wrote: '.$title.'</h3> <p>'.$body.'</p> <p>Posted on: '.$sdate.'<br/> The accused"s <a href="'.$accusedfacebook.'">Facebook</a><br/> The accused"s <a href="'.$accusedmyspace.'">Myspace</a><br/> The accused"s <a href="'.$location.'">'.$location.'</a> </div> </div> '; } } return $fullstory; } When I run this I get some errors, I tried tweaking the code ending the loops once the variables had been built then just echoing the information out after but that just wouldn't echo anything out and what I got was a blank screen. If anyone can help it would be greatly appreciated! Thanks
×
×
  • 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.