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. 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"); } ?>
  9. I can't for the life of me, work this out. Any ideas?
  10. Hi all, I think im missing something silly here <?php $array = array("/black.jpg", "/white.jpg"); $randnumber= rand(0,count($array)-1); echo'<img src="$array[$randnumber]" />; ?> I'm trying to get $array[$randomnumber] to be part of the url. Any thoughts? Thanks
  11. Thanks, I'll give that a go tomorrow!
  12. Attached [attachment deleted by admin]
  13. Hi, actually what I am looking for is to only display the days on the top row and then each event under the appropriate heading. eg go shopping goes under Monday and order take-away would be under Friday's heading for example. Attached my plan
  14. Thanks! $result = mysql_query("select * from table ORDER BY Day,StartTime"); echo '<table border="0">'; while($r=mysql_fetch_array($result)){ $Show=$r["Show"]; $StartTime=$r["StartTime"]; $EndTime=$r["EndTime"]; $Day=$r["Day"]; $Day++; echo"<tr>"; echo "<td>$Show</td><td> $StartTime</td> <td> $EndTime</td><td> $Day</td>"; echo"</tr>"; } echo "</table>";
  15. Hi all, I have a PHP connection to a database which retreives data such as Name, Day, StartTime and EndTime, I want to display the data in a table like so: Monday Tuesday Wednesday.... first event first event second event second event third event third event At the moment I have all the data in one column: Events: one (Monday two (Monday) three (Monday) one (Tuesday) two (Tuesday) etc etc Is there a sample of how to do this somewhere? Thanks!
  16. Hi all, I have this box which i want to indent by say 1 or 2 spaces. How would I best do this? Thanks <html> <head> <title>Message Us</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="/URL REMOVED method="post"> <div align="left">Message Us<br> <textarea name="message" rows="8" cols="16""; ></textarea> <br> <input type="submit" name="submit" value="Send"> </div> </form> </body> </html>
  17. Okay, I'll try to read through it again
  18. I understand this, but how do I implement it into my code?
  19. hi all, Does anyonw know how I would limit the size of the file upload to 5mb in the following? $filename = "../../../../shares/shows/{$_SESSION['directory']}"; if (is_dir($filename)) { echo "Your show folder exists"; echo "<br>"; $allowed_types = array('mp3', 'mp2', 'mp1', 'wav', 'ogg'); foreach($_FILES as $file_name => $file_array) { if (is_uploaded_file($file_array["tmp_name"])) { $image_extension = strtolower(str_replace(' ', '', $file_array["name"])); $image_extension = explode('.', $image_extension); $image_extension = strtolower($image_extension[count($image_extension) - 1]); if (in_array($image_extension, $allowed_types)) { move_uploaded_file($file_array["tmp_name"], $filename.'/'.$file_array["name"]) or die ("ERROR: Couldn't copy"); echo "The File: ".$file_array["name"]."<br/>\n"; echo "Was uploaded"; } else { echo "ERROR: You can not upload this type of file. <br> Allowed file types: MP1, MP2, MP3, WAV and OGG."; } } } } Thanks
  20. Error in the above code: New code: <?php //connect to DB with user and pass require_once 'mysql_connect.php'; //query $DJshows = mysqli_query($mysqli, "SELECT * FROM schedule"); while ($show = mysqli_fetch_assoc($DJshows)) { echo "<option value=\"{$show['Show']}\">{$show['Show']}</option>"; } ?>
  21. Hi all, The folowing code takes the row "Shows" from a database table and puts it into an option drop down to select from. I want to be able to remove apostrophies: ' and slashes / and \ from the drop down box results, but leave them intact on the database. Any ideas? I thought about making an array of ' / \ and then saying if each row form the query result contains one or more of these, then remove them from the row list but i'm not advanced enough! Thanks! <?php require_once 'mysql_connect.php'; $DJshows = mysqli_query($mysqli, "SELECT * FROM schedule"); str_replace("'", "", "$DJshows"); while ($show = mysqli_fetch_assoc($DJshows)) { echo "<option value=\"{$show['Show']}\">{$show['Show']}</option>"; } //str_replace("'", "", "$show['Show']"); ?>
×
×
  • 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.