Jump to content

p_tru

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

p_tru's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. it still doesn't work. i can't seem to be able to echo out the url. and all the username and password numbers have been edited just to give people an idea on what should be in those variables.
  2. [!--quoteo(post=353845:date=Mar 11 2006, 04:55 AM:name=Kyle Soule)--][div class=\'quotetop\']QUOTE(Kyle Soule @ Mar 11 2006, 04:55 AM) [snapback]353845[/snapback][/div][div class=\'quotemain\'][!--quotec--] Whoops! Not to even mention it printed out the same thing three times :) The below script works fine - [code]<?php echo "<table><tr><td>"; $cnt = 1; while( $row = mysql_fetch_assoc($list_result) ) {          print "<td>";     print "<img class='image' width='80px' height='150px' src='$row[picture]'             href='./recommendation.php?id=$row[item_id]' alt='Picture'><br>\n";               print "<a href='./recommendation?id=$row[item_id]>$row[Title]</a><br>$row[cost]\n";            if($cnt == '3') {         print "</td></tr><tr><td>";         $cnt = 0;     }     else {         print "</td><td>";     }                $cnt++;     } print "</td></tr></table>"; ?>[/code] [/quote] I try the code above but all it seems to do is show one picture??? plz help Petey
  3. Hi i just want help with the klayout for my site, at the moment the layout of the pictures in jus all in one line on d center of the page. What i wan to know is how do i layout the pictures so there are three, then below them three are another three, so basically rows of three pics?? This is my code at the moment for the layout for the pics: [code] while ($row= mysql_fetch_array($list_result, MYSQL_ASSOC)){ echo'<td><img class="image" width =80px height =150px src="' .$row["picture"].  '"  href="recomendation.php?id=' .$row['item_id'] . '" alt="picture"/><br> <a href="recomendation.php?id=' .$row['item_id'] . '">' .$row['Title'].  '</a><br>' .$row['cost'].  '</td>'; }//while [/code] plz Help! Petey
  4. k thanks, i'll give that a go. thanks for the tip.
  5. i'm trying to send a text message using a url but it doesn't seem to be working and i can't see errors in my coding, can someone help me i would be very grateful. [code] <?php //connect to database include 'db.private';                 $connection = mysql_connect($hostname,$username,$pwd)or die(mysql_error());        mysql_select_db($databaseName, $connection)or die(mysql_error()); SESSION_START(); if ($_SESSION[validated] == "yes") {//a      if (isset($_POST['Submit'])) {//b $user = "john"; $password = "boy"; $api_id = "198"; $baseurl ="http://api.clickatell.com"; $text = urlencode("You have successfully booked your seat"); $to = "44784552"; // auth call $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id"; // do auth call $ret = file($url); // split our response. return string is on first line of the data returned $sess = split(":",$ret[0]); if ($sess[0] == "OK") {//c $sess_id = trim($sess[1]); // remove any whitespace $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text"; // do sendmsg call $ret = file($url); $send = split(":",$ret[0]); if ($send[0] == "ID")     echo "success<br>message ID: ". $send[1];     else     echo "send message failed";     } //c     else {     echo "Authentication failure: ". $ret[0];     exit();       } }//b //a }else {     echo "you have not logged in"; } ?> [/code]
  6. i'm trying to send a text message using a url but it doesn't seem to be working and i can't see errors in my coding, can someone help me i would be very grateful. [code] <?php //connect to database include 'db.private';                 $connection = mysql_connect($hostname,$username,$pwd)or die(mysql_error());        mysql_select_db($databaseName, $connection)or die(mysql_error()); SESSION_START(); if ($_SESSION[validated] == "yes") {//a      if (isset($_POST['Submit'])) {//b $user = "john"; $password = "boy"; $api_id = "198"; $baseurl ="http://api.clickatell.com"; $text = urlencode("You have successfully booked your seat"); $to = "44784552"; // auth call $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id"; // do auth call $ret = file($url); // split our response. return string is on first line of the data returned $sess = split(":",$ret[0]); if ($sess[0] == "OK") {//c $sess_id = trim($sess[1]); // remove any whitespace $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text"; // do sendmsg call $ret = file($url); $send = split(":",$ret[0]); if ($send[0] == "ID")     echo "success<br>message ID: ". $send[1];     else     echo "send message failed";     } //c     else {     echo "Authentication failure: ". $ret[0];     exit();       } }//b //a }else {     echo "you have not logged in"; } ?> [/code]
  7. [!--quoteo(post=353599:date=Mar 10 2006, 12:33 PM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Mar 10 2006, 12:33 PM) [snapback]353599[/snapback][/div][div class=\'quotemain\'][!--quotec--] $_SESSION['username'] = $user; that will make the session username to be what ever $user is on that page. are you sure youve got this the wrong way around? [/quote] I try it the other way and it seems to work now, so thanks Petey
  8. Yes i have session capability, this is the other page i am trying to use the session: [code] <?php session_start(); include('head.inc'); ?> <?php $_SESSION['username'] = $user; echo '<table><tr>'; $list ="SELECT i.title, i.cost, i.picture FROM item i, Recommended_item r, p_history p, customer c WHERE r.item1_id = p.ItemNo AND r.item2_id = i.item_id AND p.customer_id = c.customer_id AND c.username = '$user'"; $list_result = @mysql_query($list,$conn); while ($row= mysql_fetch_array($list_result, MYSQL_ASSOC)){ echo'<td><img class="image" width =60px height =100px src="' .$row["picture"].  '" alt="picture"/><br> <a href="User.php?id=' .$row['Title'] . '">' .$row['cost'].  '</a><br>' .$row['cost']. '<br><h1>Recomended Items</h1></td></tr><tr>'; } echo '</tr></table>'; ?> <?php include('foot.inc');?>[/code] Is this right to use with my other code where i created the session??? HELP! Petey
  9. I am trying to use sessions on one of my pages but the session does not seem to be working, can someone tell me if i have created the session right: [code] <?php session_start(); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?php ///connect to the database $conn = @mysql_connect("mysql.cms.gre.ac.uk","tp311",password); @mysql_select_db ("mdb_tp311", $conn); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="pete.css" /> </head> <body> <?php if (isset($_POST['login'])) {   $message = NULL; /* the following code checks whether anything has been entered into the two text boxes */ if (empty($_POST['user'])) { $user = FALSE; $message .= '<p>whats your username</p>'; } else { $user = $_POST['user']; } if (empty($_POST['Pass'])){ $Pass = FALSE;   $message .='<p>password</p>';    } else {   $Pass = $_POST['Pass'];    }              if ($user && $Pass){ $query = "SELECT username FROM customer WHERE username='$user' AND password ='$Pass' "; $result = @mysql_query ($query,$conn);                            if ($result){ $row = mysql_fetch_array ($result, MYSQL_NUM);                  //mysql_fetch array fetches a result row as an assosiative array, numeric or both                            if ($row){/*a*/ $_SESSION['username'] = $row[0];                  echo '<p>match found: you are now logged in</p><br> <p>Please Click <a href="User.php"><u>here</u></a></p>'; $_SESSION[validated] = "yes";      }/*a*/ exit();                  /*display wrong password or username*/     } else {        $message .= 'no match found';    }    } } ?> <table class="main"> <tr><td colspan="2"><img src= ""/></td><td> <?php if (isset( $_SESSION['username'] )) { echo '<p><a href="logout.php">Logout</a></p><br/>'; }else{ echo "<form action='" . $_SERVER['PHP_SHELF'] . "' method='POST' />"; echo "<div align='right'>"; echo "Username:<input type='text' name='user' value='"; if(isset($_POST['user'])) {   echo $_POST['user']; } echo "' ><br>"; echo "Password:<input type='password' name='Pass' value='"; if(isset($_POST['Pass'])) {   echo $_POST['Pass']; } echo "' ><br>"; echo "<input type='submit' name='login' value='login'></div>"; echo "</form>"; echo '<br><p><a href="reg.php">Register</a></p></td><td></td></tr>'; } ?>[/code] [b]and how can i use the username for this session and use it in a sql query[/b] Help! Petey
  10. [!--quoteo(post=353104:date=Mar 9 2006, 01:27 AM:name=sgb162)--][div class=\'quotetop\']QUOTE(sgb162 @ Mar 9 2006, 01:27 AM) [snapback]353104[/snapback][/div][div class=\'quotemain\'][!--quotec--] session_start is a necessity on any pages using sessions. Try getting it in at the top and see if that helps. [/quote] I try session_start(); but its still just showing the number 1, i heard that i might have to set the session to the username, is this right, because i am guessing at the moment the session is only getting one because it is returnin if it is true or not, [b]HOW DO I SET THE SESSION TO THE USERNAME AND WOULD THIS SOLVE THE PROBLEM???[/b] plz help Petey
  11. Hi All, I am trying to get the username for a particular user using sessions when he/she logs in from the database, then use that username in a sql query to get the require information. My code is: [code] <?php include('head.inc'); ?> <?php $variable = session_name( ); echo '<table><tr>'; echo $_SESSION['username']; $list ="SELECT i.title, i.cost, i.picture FROM item i, Recommended_item r, p_history p, customer c WHERE r.item1_id = p.ItemNo AND r.item2_id = i.item_id AND p.customer_id = c.customer_id AND c.username = '".$_SESSION['username']."'"; $list_result = @mysql_query($list,$conn); while ($row= mysql_fetch_array($list_result, MYSQL_ASSOC)){ echo'<td><img class="image" width =60px height =100px src="' .$row["picture"].  '" alt="picture"/><br> <a href="User.php?id=' .$row['Title'] . '">' .$row['cost'].  '</a><br>' .$row['cost']. '<br><h1>Recomended Items</h1></td></tr><tr>'; } echo '</tr></table>'; ?> </td> <?php include('foot.inc');?>[/code] All i get from the page is my template and the number 1 plz help me Petey
×
×
  • 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.