-
Posts
15,232 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
How to generate PDF file so it can be downloaded?
requinix replied to exphp's topic in PHP Coding Help
Except in IE, and hopefully just the older versions, the filename you link to doesn't matter. Along with the header() that says it's a PDF file, include a header("Content-Disposition: attachment; filename=report.pdf"); That will make the browser prompt to download and will use the filename "report.pdf" by default. -
mysql_fetch_array() returns the data duplicated: one array item for each numeric key (0, 1, 2) and one for each string key ("product_supplier_reference", "price", "wholesale_price"). Use mysql_fetch_assoc() to get just the string keys or mysql_fetch_row() to get just the numeric keys. Also, please try to switch to PDO or mysqli. Those two are more efficient, can make your code much safer, and offer more functionality.
-
my problem with jquery and oop php ? is there anyone ?
requinix replied to redhat2's topic in PHP Coding Help
You should probably fix it then. If you need more specific advice than that, give us more to go on than "it doesn't work". -
Along with that goes the general question of "Have you tried running the exact same command from a terminal?"
-
Get multiple parameters from URL and echo them out.
requinix replied to CBaZ's topic in PHP Coding Help
And how would this script help with that? -
Get multiple parameters from URL and echo them out.
requinix replied to CBaZ's topic in PHP Coding Help
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https'; The SERVER_PROTOCOL will never contain "https". It is always in the form "HTTP/1.x". Check $_SERVER["HTTPS"] ("on" or "off") or, if that's not available, the less reliable $_SERVER["SERVER_PORT"] (80=http, 443=https). Speaking of, you don't take into account the port number. As for $currentUrl, $name and $value do not have what you want them to have. They're only useable inside the foreach loop. -
Just checked, it is valid. Call the function named whatever the value of $this->y is. call_user_func(array($this, $this->y));
-
By the way, return $this->{ $this->y }(); is quite wrong. Even if it's syntactically valid (might be) it won't do what you want it to do.
-
Database calls every page hit or save in $_SESSION
requinix replied to iarp's topic in PHP Coding Help
Unless you have something unusual you'll do a lot more reading than writing. Keep it in the session (or a cache) and update your database when it changes. -
...has been turned off in the new version you have, which is exactly how it should be. $newcontent = (isset($_POST["newcontent"]) ? (string)$_POST["newcontent"] : "");
-
But rest assured that the REMOTE_ADDR will be a valid IP address. There's just no guarantee that it's actually the IP address of the user - could be a proxy, could be spoofed.
-
You have to get the values of $iterator and such with $unit->iterator, not $unitlist->unit->iterator.
-
There's also the inverse: $types = array('Word','Excel','PDF'); $row = $db->get_row("SELECT doctype FROM documents WHERE id = 100"); if (in_array($row["doctype"], $types)) { // ... } else { // ... }
-
Yes, it's definitely the standard way to include files. There are alternatives for different circumstances. And yes, it will work on your local server. It'll work anywhere so long as the DOCUMENT_ROOT is defined (it practically always is) and the path to the file from there is "/template.php" (it's in that directory). If your local setup is different and you need a subfolder, like "/mydomain/template.php", then it will not work because the path is different.
-
And have you checked the error logs to see what happened?
-
And where do you define $dev?
-
Fail to input dataColumn count doesn't match value count at row 1
requinix replied to Taku's topic in PHP Coding Help
The number of fields you mention in your INSERT does not match up with the number of values you provided. Something's extra or something's missing. -
What's in conn.php? [edit] Assuming there's a mysql_connect() in there, be sure to not post the username you tried to connect with. And while I'm at it, the error message is telling you that you didn't put the password in. You probably need to.
-
foreach ($foo->new_occ as $room => $occupants) { $adults = (isset($occupants["adults"]) ? $occupants["adults"] : 0); $children = (isset($occupants["children"]) ? array_sum($occupants["children"]) : 0); echo "Room {$room} has ", $adults + $children, "occupants\n"; }