Jump to content

soak

Members
  • Posts

    219
  • Joined

  • Last visited

    Never

Everything posted by soak

  1. http://www.phpfreaks.com/forums/index.php/topic,248276.msg1162365.html#msg1162365 Still applies. I don't think there is a problem. the 302 means that somewhere your code is redirecting which looks to be causing SQL Inject me to think there is a problem. Are you redirecting if bad data is received?
  2. When does this code get included? Is it in functions? // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");
  3. Have you set the correct details here: $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="forum"; // Database name
  4. Just get rid of your connect function (or do not call it). It's connecting to the db in a function and doing nothing with the results. I'm guessing this is overwriting the connection you've just created above it.
  5. Seems as though $con isn't being instantiated correctly. If it helps, this is what my PDO details look like although mine is in a class.: <?php try { db::$__db = new PDO('mysql:host='.DB_SERVER.';'.(DB_PORT ? 'port='.DB_PORT.';' : '').'dbname='.DB_DATABASE, DB_USER, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => true)); db::$__db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); return db::$__db; } catch (PDOException $e) { trigger_error('Unable to connect to the database.', E_USER_ERROR); } It should be wrapped in a try catch as it triggers an exception if the connection fails. Can you var_dump($con); after you instantiate it please? @Dj Kat, so that you can extend the class with your own functions to make it even easier to access the data you need. Also to allow you to abstract yourself away from that particular implementation. My DB class uses PDO if available and mysqli if it is not and I only have to use 1 set of functions to access it. I could just as easily hook it into adodb and use it with Postgres. EDIT: Sorry, meant to say that yep, connection details look fine. For some reason $con either isn't being set or isn't making it into the function.
  6. Do you get access to the php manual to look up the needle / haystack order of strpos?
  7. Which suggests that $_POST['deleteband'] is not being set. Try it, it might work, it might not but you've got nothing to lose either way.
  8. I think the problem might be that you have two fields in your form called deleteband. If the browser uses the second one then because the field is of type image deleteband_x and deleteband_y will be set instead of deleteband. Change the name="" attribute of your image field.
  9. Try this: http://netevil.org/blog/2006/nov/http-post-from-php-without-curl
  10. The was because I copy and pasted the javascript from the linked page and added a few $ signs to it ;-)
  11. You're using the variable $text as an array and also as a string to store the results to echo later. Rename one of them.
  12. That's how bind_params works, it is a bit odd isn't it. Much prefer PDO myself, loads easier to use.
  13. Any error messages? try error_reporting(E_ALL); I'm thinking that there's a possibility that your first column is an auto_inc and that you need to pass it null for it to work correctly. As you're casting it as an int it may not be getting to the db as null. If that's the case then try moving the null from the bind_param to the query itself.
  14. <?php function factorise($numm) // To calculate the prime factors of a number { $newnum = $numm; // Initialise $newtext = ""; $checker = 2; // First possible factor to check while ($checker*$checker <= $newnum) // See if it is worth looking further for factors { if ($newnum % $checker == 0) // If the possible factor is indeed a factor... { $newtext = $newtext . $checker; // ...then record the factor $newnum = $newnum/$checker; // and divide by it if ($newnum != 1) // then check whether it is not last... { $newtext = $newtext . "."; // ...and if so prepare for the next } } else // otherwise... { $checker++; // try the next possible factor } } if ($newnum != 1) // If there is anything left at the end... { // ...this must be the last prime factor $newtext = $newtext . $newnum; // so it too should be recorded } if ($newtext == "" . $numm) // If the only prime factor is the original... { $newtext = "Prime: " . $newtext; // ...then note that it must have been prime. } return $newtext; // Return the prime factors }
  15. $uploadsDirectory = dirname(__FILE__) . '\\uploaded_files\\';
  16. Pretty sure you're stuck with a foreach. If you need to search it often it may be worth generating a key array. Loop it once and set $keyArray[$key] = $value['id']. That way you can just search your keyarray (with in_array() - get the key with array_search()) and use that to get the correct data from your main data array. If you need me to explain more let me know.
  17. LOL :slap: Technically my code should work though ;-p If there are any factors in those primes it'll definitely find them!
  18. $column_qnty = $column_quantity.$qnty."\n"; $column_part = $column_productcode.$part."\n"; $column_desc = $column_productname.$desc"\n"; You've used $column_qnty and $column_quantity, same with the two lines after it. Both variables should be the same as the ones you add to your pdf file further down the page. You also need to initialise them at the start of your script: $column_qnty = ""; $column_part = ""; $column_desc = "";
  19. <?php $factors = array(); for ($check = 2; $check <= sqrt($num); $check++){ if ($num % $check == 0){ echo "This number is not prime. because $check is a factor! <a href=\"prime.php\">Try another number?</a>"; die(); } } else { $factors[] = $check; } echo "Number is prime! <a href=\"prime.php\">Try another number?</a>"; echo "Factors are: ".implode(', ', $factors); die();
  20. Got it.... possibly: $column_desc = $column_productname.$desc"\n"; should be $column_desc = $column_productname.$desc."\n";
  21. After $uploadsDirectory is set in your code add the following lines: echo "<pre>"; var_dump($uploadsDirectory); var_dump(dirname(__FILE__)); die; And post these two paths please. It could be that the tmp dir is not writeable but I think that unlikely TBH. If it is then php is set up badly by your host.
  22. Ahhh, I see, you're putting them all in 1 big MultiCell, not in seperate Cell's. In that case, ensure that error reporting is on and issue a die(); before your pdf is output. Put this at the very start of your script: error_reporting(E_ALL); ini_set('display_errors', 1); I suspect there's an error in your code somewhere.
  23. I suspect that you can't unless it's there already or you have a dedi. Ask GoDaddy to be sure but if it's not installed already then don't hold your breath.
  24. It looks as though it will print 1 row and that's it. Does your "working" version print more than 1 product row? I was thinking of something like this: <?php //Select the Products you want to show in your PDF file $result=mysql_query("select Code,Name,Price from Products ORDER BY Code",$link); $number_of_products = mysql_numrows($result); //Initialize the 3 columns and the total $column_code = ""; $column_name = ""; $column_price = ""; $total = 0; //Create a new PDF file $pdf=new FPDF(); $pdf->AddPage(); //Fields Name position $Y_Fields_Name_position = 20; //Table position, under Fields Name $Y_Table_Position = 26; //First create each Field Name //Gray color filling each Field Name box $pdf->SetFillColor(232,232,232); //Bold Font for Field Name $pdf->SetFont('Arial','B',12); $pdf->SetY($Y_Fields_Name_position); $pdf->SetX(45); $pdf->Cell(20,6,'CODE',1,0,'L',1); $pdf->SetX(65); $pdf->Cell(100,6,'NAME',1,0,'L',1); $pdf->SetX(135); $pdf->Cell(30,6,'PRICE',1,0,'R',1); $pdf->Ln(); //For each row, add the field to the corresponding column while($row = mysql_fetch_array($result)) { $code = $row["Code"]; $name = substr($row["Name"],0,20); $real_price = $row["Price"]; $price_to_show = number_format($row["Price"],',','.','.'); $column_code = $column_code.$code."\n"; $column_name = $column_name.$name."\n"; $column_price = $column_price.$price_to_show."\n"; //Sum all the Prices (TOTAL) $total = $total+$real_price; //Now show the 3 columns $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position); $pdf->SetX(45); $pdf->MultiCell(20,6,$column_code,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(65); $pdf->MultiCell(100,6,$column_name,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(135); $pdf->MultiCell(30,6,$column_price,1,'R'); } //Convert the Total Price to a number with (.) for thousands, and (,) for decimals. $total = number_format($total,',','.','.'); $pdf->SetX(135); $pdf->MultiCell(30,6,'$ '.$total,1,'R'); //Create lines (boxes) for each ROW (Product) //If you don't use the following code, you don't create the lines separating each row $i = 0; $pdf->SetY($Y_Table_Position); while ($i < $number_of_products) { $pdf->SetX(45); $pdf->MultiCell(120,6,'',1); $i = $i +1; } $pdf->Output();
  25. Could you use foreach() instead? That way it will just loop the values in your array, no need to check for bounds.
×
×
  • 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.