shaunrigby
Members-
Posts
196 -
Joined
-
Last visited
Never
Everything posted by shaunrigby
-
how to echo the current row in mysql WHILE loop
shaunrigby replied to dsaba's topic in PHP Coding Help
<?php echo $row['columnName']' ?> Where columnName is the name of the column you want to print from your DB -
Dude, we are swamping the kid with code, alohat, try my code, then post back th me the error message you are receiving, then do the same with madtechcie's code
-
what error message does my script return?
-
what are you trying to pass?
-
remove: that should solve your problem
-
what line? print that line...
-
post the page you are setting the session vars and post the page thats using the session vars
-
What does it return?
-
Code revamp: <?php $time=time(); $timeout=time()+(60*60); #now+1hour ` mysql_query("UPDATE `username` SET `timestamp` = '" . $time . "' WHERE `memberId` = '" . $id . "' LIMIT 1") or die("Update Query 1: " . mysql_error()); $query = mysql_query("SELECT * FROM `surv_member` WHERE `online`= '1' AND `timestamp` >= '" . $timeout . '") or die("SELECT Stament: " . mysql_error()); while($row=mysql_fetch_array($query)){ mysql_query("UPDATE `username` SET `online` = '0' WHERE `memberId` = '" . $row['id'] . "' LIMIT 1") or die("Update Query 2: " . mysql_error()); print $row['online']; } mysql_close(); ?>
-
Also, please read: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
-
It all work now m8?
-
try taking out the exit; afterwards
-
varchar(1) is easiest
-
Change : $conn = db_connect(); if (!$conn) return "Could not connect to database server - please try later."; // check if username is unique $user_name = $_POST['user_name']; $result = mysql_query("select * from members_info where user_name='$user_name'"); if (!$result) return "Could not execute query". mysql_error(); if (mysql_num_rows($result)>0) return "<p class=\"genmed\">That username is taken - go back and choose another one.</p>"; To: $conn = mysql_connect($host,$username,$password) or die("Could not connect to database server - please try later." . mysql_error());//Remove . mysql_error() after you have finished developing your code mysql_select_db($dbname) or die(mysql_error()); // check if username is unique // $user_name = $_POST['user_name'];//Why you setting this? you are obtaining it VIA your function, $query = mysql_query("SELECT * FROM `members_info` WHERE `user_name` = '" . $user_name . "'") or die(mysql_error()); $result = mysql_num_rows($query); if ($result > 0 ) { return true; } else { return false; }
-
Are you passing the ID via URL? or via a form? URL = $_GET Form = form method $_GET/$_POST also, try $_GET[i'd']
-
Lets make it easier for ourselves, Trium, please post the function wrapped in code tags
-
did that appear on your screen? please wrap [ code][ /code] tags around your code to make it easier for us to understand, and also plus post the function to work out why it is returning NULL
-
in your while statement put print "UPDATE `username` SET online='0' WHERE memberId='$row[id]' LIMIT 1"; and check that against your database Google "MYSQL UPDATE STATEMENT" (minus the " 's) for what Syntax to use for UPDATE statements
-
that is if s/he uses return true; and in what context (1/0, true/false)
-
Try using the switch case that i posted to you in another thread, if you CBA then change your elseif to else if { //code }
-
if($reg_result === TRUE){ //INSERT PROCESSING HERE } else { //UL DUMBA$$ SOMEBODY HAS YOUR PREFERRED NAME }
-
add mysql_select_db($database); Underneath your MySQL_Connect function
-
Lookup "php sessions" (minus quotes) on Google to find out how to add variables to a session, and use it to determine if the person logged in is allowed to edit it using a boolean true/false
-
Right now? Windoze EXPEE, because I find Ubuntu extremely complicated, and although I have WAMP I am not exposed directly to the internet
-
Sorry, what is your code again?