Jump to content

grahamb314

Members
  • Posts

    128
  • Joined

  • Last visited

Everything posted by grahamb314

  1. I tried this but it just said Array, Array.. {html_table loop=$table}
  2. I'm using smarty and have an array called $table Array ( [0] => Array ([0] => title [1] => criteria [2] =>date ) [1] => Array ( [0] => heading[1] => a[2] => b[3] => c[4] => d [5] => e[6] => f[7] => g [2] => Array ( [0] => 1[1] => 0 [2] => 100 [3] => 0 [4] => 4 ) [3] => Array ( [0] => 2[1] => 100 [2] => 0 [3] => 0 [4] => 1 ) [4] => Array ( [0] => 3[1] => 25 [2] => 0 [3] => 75 [4] => 4 ) [5] => Array ( [0] => 4[1] => 22.222222222222 [2] => 0 [3] => 77.777777777778 [4] => 9 ) [6] => Array ( [0] => 5[1] => 0 [2] => 14.285714285714 [3] => 85.714285714286 [4] => 7 ) [7] => Array ( [0] => 6[1] => 50 [2] => 50 [3] => 0 [4] => 8 ) ) I want to display this in an html table by using smarty, I cannot work out the smarty syntax to loop the array and get the table to output like this: Any ideas?
  3. Nope. Why does a password have to be unique? - I'm sure that there is someone else out there who has a password the same as mine for some things. If you really wanted to, you can check against existing passwords in your DB. If you get more than one result, generate another.
  4. How about something simple like: function generate_password() { $length =8; $chars = "abcdfghjkmnpqrstuvwxyzABCDEFGHIJKMNPQRSTUVWXYZ23456789"; $size = strlen($chars); for($i = 0; $i < $length; $i++) { $str .= $chars[rand(0, $size -1)]; } return $str; }
  5. I'm trying to learn arrays and I have this problem: I have a variable $a which is a result from a from a database query If I echo it I get: forenamesurnamedate_of_birthgenderpaypal_addresspayment_planaddress_line_1address_line_2address_cityaddress_zip_post_codeaddress_countrytelephonemobilewhere_did_you_hearreceive_newsletter If I var_dump($a) I get: string( "forename" string(7) "surname" string(13) "date_of_birth" string(6) "gender" string(14) "paypal_address" string(12) "payment_plan" string(14) "address_line_1" string(14) "address_line_2" string(12) "address_city" string(21) "address_zip_post_code" string(15) "address_country" string(9) "telephone" string(6) "mobile" string(18) "where_did_you_hear" string(18) "receive_newsletter" My question is, how do I get each value from a? It looks like an array to me because it holds multiple strings. I need to get the first, second and third elements printed on the page and used in other areas of my program. Thanks in advance
  6. Just using the one connection solved this issue. I had two for checking something earlier and never bothered to change the ocde back to using the one. Perhaps the mysql service had reached it's maximum number of permitted connections or something? Anyhow, the problem no longer exists. Thanks for all your help
  7. If you want to keep it all in the query, you could use CASE statements, although it's not a clean way of doing things http://dev.mysql.com/doc/refman/5.0/en/case-statement.html
  8. What phppaper said
  9. I've decided to move over to using Prepared statements for security purposes, however I'm having problems with the following code. Any help or suggestions would be appreciated Output: You are Logged In Fatal error: Call to a member function bindParam() on a non-object in [b]xxxxxxx[/b]/login.php on line 34 Code: <?php include "functions.php"; $db_connection = db_connect(); $db_connection2 = db_connect(); $login_statement = $db_connection->prepare("SELECT COUNT(*) AS accounts FROM `accounts` WHERE `email` = ? AND `password` = ?"); $test_stmt = $db_connection2->prepare("INSERT INTO `test` (`test`) VALUES (:tst)"); login($_POST[email],$_POST[password],$login_statement); log_login($test_stmt); function login($email,$password,$login_statement){ $login_statement->bind_param("ss", $email, $password); $login_statement->bind_result($accounts); $login_statement->execute() or die ("Could not execute statement"); while ($login_statement->fetch()) { if ($accounts==1){ echo "<br/> You are Logged In <br/>"; } else{ echo "<br/>Credentials Invalid<br/>"; } } } function log_login($test_stmt){ $test_stmt->bindParam(':tst', $tst); //< ********LINE 34******* $tst="blah"; $test_stmt->execute() or die ("Could not execute statement"); } ?>
×
×
  • 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.