Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. What is db_connection? Is it an instance of the PDO db link? http://php.net/manual/en/pdostatement.rowcount.php You should be able to use num_rows, i.e. if ($q->fetchColumn()==0) //throw error here
  2. I would definitely recommend following some online tutorials or books, I bought 'Kevin Yanks - Build a Database Driven Website using MySQL & PHP' book and followed all the tutorials and teachings. It helped me a lot http://www.amazon.com/Build-Database-Driven-Website-Using/dp/0957921802
  3. //Could you put some debug code in and test it out? //Do you see your 'Connected' message? <?php //also, lets turn on error reporting whilst it's not working error_reporting(E_ALL); require 'db/connect.php'; echo 'Connected'; //Added to be sure to be sure connected if(isset($_GET['first_name'])) { $first_name = trim($_GET['first_name']); if($insert = $db->query(" INSERT INTO people(first_name, last_name, bio, created) VALUES ('{$first_name}', 'Garrett', 'I\'m a web developer', NOW()) ")) { echo $db->affected_rows; } else { echo "FAILED WRITING"; } } else { exit("$_GET not SET - ".print_r($_GET,true)); } ?>
  4. Now the question, how to create a multidimensional array from a 1d array? i.e. $key = 'one_two_three'; $multiKeys=explode('_',$key); //now multikey = array('one','two','three'); //I'd like to convert this to $newArray['one']['two']['three']; I've tried a recursive function though I need to get to the end of the array and I think I've just been staring at this one for a little too long =/ Any help would be appreciated,
  5. Perfect! Thank you Strider, I'm definitely on the right track now - I'll let you know how it goes
  6. You can also set your radio buttons to be an array, echo '<br><b>',$myrow["Question"],'</b><br> <br><input type="radio" name="ans['.$myrow["Q_ID"].']" value="A1">'.$myrow["A1"].'<br> <input type="radio" name="ans['.$myrow["Q_ID"].']" value="A2">'.$myrow["A2"].'<br> <input type="radio" name="ans['.$myrow["Q_ID"].']" value="A3">'.$myrow["A3"].'<br> <input type="radio" name="ans['.$myrow["Q_ID"].']" value="A4">'.$myrow["A4"].'<br> <br>'; and then in your php foreach ($_POST['ans'] AS $key=>$value) { //$key will = $myrow["Q_ID"]; //$value will = $myrow["Ax"] }
  7. you can't get the mac address of the client AFAIK. You'll have to use either IP address or cookies, why would anyone want to alter their cookies for your site?
  8. I'm trying to convert a one dimensional array into a multidimensional array by grouping matching parts of the keys, i.e. array('onetwothreefour'=>'value', 'onetwothreesix'=>'value2') would become array('onetwothree'=>array('four'=>'value', 'six'=>'value2')); Essentially I'm trying to convert XML to YML and have a one dimensional array of the XML with index => value. I've been staring at it for a while now and have tried a few recursive functions to build it though I've come to a few dead ends and would appreciate any words of wisdom if someone can spot the answer easier than I
  9. you need to specify a file path for fopen, not the content. It will attempt to create the file if it does not exist and you use 'w' as the second argument. $fp = fopen('data.txt', 'w'); fwrite($fp, '1'); fwrite($fp, '23'); fclose($fp); http://www.php.net/manual/en/function.fwrite.php
  10. Check you're posting the required data before echoing, Have a look at isset() if (isset($_POST['account_name'])) { //echo }
  11. session_start(); $auth= md5(date('giadmy') . '5417'); $_SESSION['auth'] = $auth; // the html <form action='page2.php'> Field one... <input type='text' name='whatever' /> etc <input type='hidden' name='auth' value='<?php echo $auth; ?>' /> <input type='submit'> //page2 .php session_start(); if (!isset($_POST['auth'], $_SESSION['auth']) || $_POST['auth'] != $_SESSION['auth']): exit('the auths did not match...'); endif; //otherwise execute your code and insert to database etc
  12. you need to check if the username exists before you insert it... or set the username as the primary key a nd use the insert on duplicate syntax
  13. yes, though it can be manipulated by a user... if you're that worried, store a hidden random value md5(date?) as a hidden form field, store it in the session and verify before inserting to database....
  14. if it is stopping other functions, it sounds like you have an error in your code somewhere and no other code will be processed once it hits the error... get webdeveloper toolbar or firebug so you can see if your javascript is executing correctly... post your code if you're still having troubles.
  15. .parent { position: relative; } .child { position: absolute; bottom: 0; right: 0; }
  16. have a look at jquery UI's datepicker - you can set the max date to today
  17. character is a mysql variable, you need to surround that fieldname with backquotes; `character` $sql="INSERT INTO child_info (first_name,middle_name,last_name,gender,birthdate,`character`,diagnosis,description,file_number) VALUES ('$_POST[first_name]','$_POST[middle_name]','$_POST[last_name]','$_POST[file_number]','$_POST[gender]','$date','$_POST[character]','$_POST[diagnosis]','$_POST[description]')";
  18. 3 is the 3rd month... march... if you want greater than march (i.e. april 2012 to march 2013, then set it to > rather than >=) not sure what you mean...
  19. SELECT CASE WHEN MONTH(date_field)>=3 THEN concat(YEAR(date_field), '-',YEAR(date_field)+1) ELSE concat(YEAR(date_field)-1,'-', YEAR(date_field)) END AS financial_year, SUM(amount_counting_field) FROM theTable GROUP BY financial_year //change the amount_counting_field to the field you want to aggregate for the years and the table name. sourced from stack overflow() #edit# if you want to select the rows in that year and not an aggregated value; SELECT * FROM theTable WHERE (month(date_field) >= 3 AND year(date_field) = 2012) OR (month(date_field) < 3 AND year(date_field) = 2013)
  20. try this. //edit forgot to add get image info & size. $imgInfo = getimagesize($img); $nWidth = 50; $nHeight = 50; $im = imagecreatefrompng($target); $newImg=imagecreatetruecolor($newwidth,$newheight); imagealphablending($newImg, false); imagesavealpha($newImg,true); $transparent = imagecolorallocatealpha($newImg, 0, 0, 0, 0); $black = imagecolorallocate($newImg, 0, 0, 0); imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent); // Make the background transparent imagecolortransparent($newImg, $transparent); imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);
  21. sorry I've never used PHP Pro Bid before; Since it's a paid for product, they should offer some level of support. Try contacting them http://www.phpprobid.com/contact.php?PHPSESSID=ed914959bd96b97dd3c633dc9fdcea12
  22. //wrote this script almost 2 years ago, hope it helps. $newImg = imagecreatetruecolor($newWidth, $newHeight); imagealphablending($newImg, false); imagesavealpha($newImg,true); $transparent = imagecolorallocatealpha($newImg, 0, 0, 0, 0); imagefilledrectangle($newImg, 0, 0, $newWidth, $newHeight, $transparent); imagecolortransparent($newImg, $transparent);
  23. I need to see the function that echos to image //look on the categories.php.php page and there will be a call to a function which echos the image... need to see that function and the code where it's being called. <img border="0" alt="Thai Stamp" src="themes/v6/img/system/noimg.gif"/>
  24. we'll need to see the code to help... how are you echoing the images?
×
×
  • 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.