Jump to content

freelance84

Members
  • Posts

    975
  • Joined

  • Last visited

Everything posted by freelance84

  1. Is this possible? Please look at the attached image. I am trying to create a team creation page for a site I am making, however I want the user to be able to see all the names they enter before the information is passed to the .php file to send it to the MySQL table. 1. So, every time the user enters a name and presses the "add name" button the name details are stored in an Javascript array and displayed in the box below. 2. When the user presses the "save team" button the team name is passed by a simple form post and the javascript array is passed to a php array and then processed ready to be passed to the MySQL table. The problem is I don't know to do the first bit (number1). Any ideas or pointers? [attachment deleted by admin]
  2. The site I am creating has 3 different types of users all of which will see a different homepage. To achieve this when a user registers the type of account is also stored in the members table, i.e. 1, 2 or 3. My question is, after the check_login.php has checked the login details I will run; if($type = 1) {.......} What's the best thing to put here if the target page is type1h.php?
  3. No sorry, I'm also storing the in the $_SESSION the username, user type, forname and surname. So i can gather that once the password has been checked at the start there is no need for it to be passed on in the $_SESSION unless required later on in the site? That actually makes more sense.
  4. OK I have another question on $_SESSION. After my "check_login" script has got the entered username and password, stripped any slashes...etc, I then add some salting to the password and run it through "sha1", the end product is called $token and this should then match the password stored in the members table in MySQL. The book I am using says to pass the original password to the $_SESSION['password']. Should I not be passing the $token as the password instead as this is what is stored in the members table, and is more secure? Or would this actually make it less secure as I would be passing the actual password stored in the table?
  5. yup that's exactly what the book i'm learning from tells me to do too. cheers
  6. Getting conflicting advice from a few different sources at the moment. A so far very solid book only shows how to use the "$_SESSION", but a few websites I've been on show tutorials with "session_register". Which should I use? pro's and con's? N.B. I am creating a website which when registered to requires a username and password to get in.
  7. Is it possible to delete/change the POST once it has been used? e.g. if (isset($_POST['number']) && isset($_POST['update'])) { $number = get_post('number'); $update = get_post('update'); } After the above has got the POST can it then either delete or change it so when in a loop it doesn't keep being used?
  8. Apologies, wasn't thinking! of course you must use the HTML notes: <!-- -->
  9. Hello, Again with a rather novice question... I have written a php file to output a html page by using the "<<<_END" "_END;" tags. Is it possible to put notes in-between these tags? When I did it the usual way of escaping them with it simply outputted the notes to the html page. Any ideas?
  10. Also i've just found a site which explains very simply the permisions for PHP: http://www.htmlite.com/php042.php
  11. ah brilliant thanks. I'll wait till 2mo then and give them a call
  12. Hi again, I've learnt PHP and MySQL from a pretty good book which uses EasyPHP 3.0. Throughout the book it tells you to use the host name as 'localhost' when connecting to a database. Is this just specific for EasyPHP or is this also the name when uploading on the real internet? Also does anybody know any good sites regarding what permissions to set php files to? There seems to be a huge array of different sites non of which i have found seem to be all that clear. Once again any help here would be very much appreciated. John
  13. Yea cheers salathe. I managed to figure out a solution to above using fetch_row in a for loop.
  14. Hi SaMike, cheers, but this still just returns one result but now in an associative array
  15. Using the more efficient extraction into an array: $data = array(); while ($row = mysql_fetch_array($result_mq1)) { $data[] = $row; } print_r($data) The print_r($data) results in the following: Array ( [0] => Array ( [0] => test AA [comment] => test AA ) [1] => Array ( [0] => test BB [comment] => test BB ) ) Is this now an associative array? echo (data[0]); this just returns 'array' How do I just return the 1st result from the array?
  16. Ok I've got the following code to get all the results of the query into one array, but it doe seem a little OTT for what it does. Is there no simpler way? $row = mysql_fetch_row($result_mq1); $rows = mysql_num_rows($result_mq1); for ($j = 0 ; $j < $rows ; ++$j) { $content = mysql_fetch_row($result_mq1); array_push($row,$content); } print_r($row);
  17. $mq1 = get_post('mq1'); $query_mq1 = "SELECT com FROM mq1 WHERE number='$mq1'"; $result_mq1 = mysql_query($query_mq1); if (!$result_mq1) die ("Database access failed: " . mysql_error()); $row = mysql_fetch_array($query_mq1); print_r($row); This returns "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL" If I apply the fetch_array to the $result_mq1: $mq1 = get_post('mq1'); $query_mq1 = "SELECT comment FROM mq1 WHERE number='$mq1'"; $result_mq1 = mysql_query($query_mq1); if (!$result_mq1) die ("Database access failed: " . mysql_error()); $row = mysql_fetch_array($result_mq1); print_r($row); ...it just returns one result and not all. Do I need to use the array_push?
  18. Or if not one move which is the simplest/ easiest?
  19. Hi, I'm pretty new to php & mysql, so this may seem very elementary: $query_mq1 = "SELECT com FROM mq1 WHERE number='$mq1_a'"; The above query selects everything from the column named "com" from table "mq1" where it matches variable "$mq1_a" from column "number". The following two lines get the query into a php variable or throw up an error if a problem arrises: $result_mq1 = mysql_query($query_mq1); if (!$result_mq1) die ("Database access failed: " . mysql_error()); My question is, is it possible to get these results into one array in one move? I can only seem to find "$row = mysql_fetch_row($result_mq1);" which only gets one result at a time. Any help here would be brilliant as I am pretty stuck. Thanks, John.
  20. The reason I want all the results to be returned is so I can use the shuffle() function to get a random result from the table
  21. Hello, new to this forum, my name's, John. I have a database in MySQL with one field, 'answers'. $query = "SELECT * FROM m$selected"; $result = mysql_query($query); if (!$result) die ("Database access failed: " . mysql_error()); $rows = mysql_result($result,0); echo ($rows); The above PHP script when added after a radio button form prints the 1st entry in the database. How do I get it to return all the results? $rows = mysql_result($result,0); Is there a value I can replace the '0' with which means all? I tried star but it didn't work. The book I'm learning from only tells me how to return individual rows, and some of the php libraries seem a bit daunting at the moment as I'm only a beginner
×
×
  • 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.