Jump to content

mofm

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by mofm

  1. Edit you post and use the tags provided plz
  2. Cross pollinate is a confusing term :S? don't worrie about the two foreach statements cross pollinating what ever that means Just rember if you need to keep any data from the foreach statement you need to store it in a unique variable. The scope of a foreach statement is just like an if statement. The variables are not lost when the for each statement executes but the nature of the statement means that $questionID and $response will only contain data that is in the last element of the array. I hope that makes sense I think you have gotten very confused somewhere. name="answerArray[1]" <------ will not make it an array all you have done here is named it answerArray[1] so in php if you want to access its data you would need to do this $_POST['answerArray[1]'] I dont bealive you can post an array to php using html. If you can id like to know about it:) but what you can do is something like this. name=var value="1;2;3;4;5;6;7;8;9;10" <?php $array=explode(';',$_POST['var']); $echo $array[6];//7 ?>
  3. I have no idea what you are asking and i don't think anyone else will, try rewording your question.
  4. Im not sure on what your asking help on :S ? But i will give it a go A foreach loop is used to loop through arrays and nothing else. If you do not want the key values you can just do this foreach ($array as $value) { //stuff u want to do here } Your code is slightly confusing you seem to be using $_POST['answerArray'] as an array. Im assuming you have modified the global variable somewhere else. If not then $_POST['answerArray'] will be a string and not an array.
  5. Hello, i am starting a large project that another developer will also be working on. What is the best way about doing this. There seems to be a lot of solutions online but a lot of them seem very difficult to setup and maybe even abit over kill. so im kinda after some reasonable suggestions. Thanks mofm
  6. Ok to fully understand what's going on here you must understand that when you pass a variable by reference you are not sending the data contained within that variable but instead sending an address of memory where the data you want is located... this is very different then just sending data. When a function executes you must understand that it has a certain level of scope, ie it cant see/edit variables out side of its { } but if you pass a variable as a reference you allow the function to directly edit a piece of memory. Let me explain with a few examples Example 1 The basics of a function <?php $a=10; $b=addOne($a); // this is simple and you should understand this echo $a; //10 echo $b; //11 function addOne($var) { return $var ++; // This function cant directly edit $a as it is outside its scope so instead we must "return" the data from the variable } ?> Example 2 Using example 1 but instead passing $a as reference. <?php $a=10; addOne(&$a); // I pass $a as a reference using & echo $a; //11 function addOne($var) // now var doesn't contain 10 but instead it contians the location of $a { $var ++; // this is like doing $a++ but it goes through $var inorder to access $a } I hope this helps you get your head round this, its not that hard like anything in php once you get the concept
  7. Although you can just use JS, I think the OP will benefit more from learning AJAX.
  8. You brain + Google will at least get you started buddy. If your not interested in giving it a shot no one else will for you.
  9. ok u need to use ajax to do what u want. have a look at http://www.w3schools.com/PHP/php_ajax_database.asp to get you started with ajax
  10. Although its Solved it does not really help u out that much . Have a look at substr() http://php.net/manual/en/function.substr.php some light reading: http://www.tizag.com/phpT/php-string-strpos.php
  11. http://php.net/manual/en/function.explode.php Explode splits a string into an array e.g. <?php $string="1&2&3&4&5&6&7"; $array=explode("&",$string); ?> Array will be 7 in lenght containg 1 2 3 4 5 6 7 so ur example would be <?php $data = "page=1&data=1:21;2:34;5:57&a=yes"; $array=explode(";",$data): //array[0] will be 1:21 //array[1] will be 2:34 //ect u get the idea, it simple from then on. //just loop though the array do as u wish then use implode to join them back to string if needed. foreach ($array as $k => $v) { // do what u want to the data here } $string=implode($array); ?> Notes on implode http://php.net/manual/en/function.implode.php ; If u want to remove elements from an array you can use unset($array[4]). http://php.net/manual/en/function.unset.php
  12. Yhe i agree with above your best bet is to make page views time out ... this will make inaccuracy's but will still work .. could this be done with ajax ?? im assumption is that it can but im no java-script expert
  13. OK some people seem to think you can make a website 100% secure ..... you can't all you do its make it harder. What your asking is how do i let my code know if a users cookies have been sniffed. All you can really do is check it against the IP/user agent etc etc witch can all be faked one way or another. If this isn't secure enough for you your next port of call is using encryption for all pages on your site this may be unpractical. The overheads of encryption can cause a lot of issues. And even then this isn't secure against man in the middle attacks so...... make your choice choose whats best for your situation and not necessarily the most secure. Today's encryption would take a ridiculously long time to crack its not really a viable option. man in the middle attacks are properly the option an hacker would go for. Mofm
  14. mofm

    Looping

    This code is all wrong ... i think you need to read up on php better mate if you want to loop somthing you need to use a counter variable so you can stop it when you want somthing like this While ($counter <=10) { dotihis dothis dothis $counter++;//adds one to counter } also since your getting $sname from the get you will only have one set of data so the same data will be entered into teh database over and over is this what you want ?
  15. i agree with teh above post its a mysql authorization problem set yourself up a user name and password teh best way to do this is get php myadmin if you dont allready. all you have to do it extract it in ur sever root. and the go to its Directory in ur web broowser ie : http://localhost/phpmyadmin/ then change <?php //Users Database settings $host="localhost"; $username="root"; $password=""; $db_name="users"; to somthing like this <?php //Users Database settings $host="localhost"; $username="mysetusername"; $password="mysetpassword"; $db_name="users";
  16. can no one here help me then ?
  17. well you did post it in the "PHP HELP" section
  18. its not hard to make the code below a function foreach($_GET as $key => $value) { { if($value<=10) { if(is_string($value)) { $$key = $value; } } } }
  19. i think ur after somthing like this ? <? foreach($_GET as $key => $value) { $$key = $value; } ?>
  20. maybe it would be better to have a support form and just get users to submit help requests using that and you can get the script to email you. this would be the best and most easy way to do things in my opinion. Good luck Mofm
  21. well thanks for looking anyway anyone else any ideas thanks mofm
  22. simple things get me stumped for agies dont worrie so annoying well im glad u got it sorted nneed anymore help give me a buzz dway_row@hotmail.com (msn)
  23. Im makeing a image gallery and im using an array to organise all my data i want each indervidual album to go acroos the mage like this : Album album2 album image album image album description ablumb decription etc etc ... i only want 4 to show on any one row Well hers my code and it only returns 1 row (4) albums when there is 7 in the database: <table width="650" border="0"> <?php require '../includes/functions.php'; require '../includes/connect.php'; require '../includes/settings.php'; session_start(); /************************************************************ Adjust the headers... ************************************************************/ header("Expires: Thu, 17 May 2001 10:17:17 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 $album_id=""; if(empty($album_id)) { $albums_query = "SELECT * FROM albums"; if($albums_result=mysql_query($albums_query)) { $counter=0; $albums=array(); $set=0; while($albums_array=mysql_fetch_array($albums_result)) { if ($counter%4==0 && !$counter==0) { $set++; } $albums[$set][$counter][0]=$albums_array['name']; $albums[$set][$counter][1]=$albums_array['description']; $albums[$set][$counter][2]=$albums_array['userid']; $albums[$set][$counter][3]=$albums_array['image']; $albums[$set][$counter][4]=$albums_array['user']; $albums[$set][$counter][5]=$albums_array['date']; $albums[$set][$counter][6]=$albums_array['id']; $counter++; } $setcount=0; while ($setcount<=$set) { $counter2=0; $rowcounter=0; while ($rowcounter<7) { while($counter2<4) { echo "<td colspan=\"3\">".$albums[$setcount][$counter2][$rowcounter]."</td>"; $counter2++; } echo"</tr><tr>"; $rowcounter++; $counter2=0; } $setcount++; } }else{ //sqlerror } } ?> </table>
  24. heres is a login sytem iv done a few days ago have a look <?php $mysql_login_query="SELECT * FROM users WHERE username ='$userdet_username' AND password = '".md5($userdet_password)."'"; if ($mysql_login_result =mysql_query($mysql_login_query)) { $loginarray=mysql_fetch_array($mysql_login_result); if(mysql_num_rows($mysql_login_result) ==1) { if($loginarray['confirmed']=="yes") { $_SESSION['logedin']=TRUE; $_SESSION['username'] = $loginarray['username']; $_SESSION['userid'] = $loginarray['id']; $_SESSION['datejoined'] = $loginarray['datejoined']; $_SESSION['nicname'] = $loginarray['nicname']; $_SESSION['email'] = $loginarray['email']; $_SESSION['theme'] = $loginarray['theme']; $_SESSION['lastonline'] = $loginarray['lastonline']; $_SESSION['fname'] = $loginarray['fname']; $_SESSION['sname'] = $loginarray['sname']; $_SESSION['accesslvl'] = $loginarray['accesslvl']; $_SESSION['hidemail'] = $loginarray['hidemail']; echo "loged in correct"; }else{ header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/login.php?username=".$userdet_username."&error=notconfirmed"); } }else{ header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/login.php?username=".$userdet_username."&error=wrongdetails"); } ?> i removed some of the things you dont need as id rather keep the code to myself
×
×
  • 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.