
dcro2
Members-
Posts
489 -
Joined
-
Last visited
Never
Everything posted by dcro2
-
$pick = ""; foreach($results as $result) { $pick .= "(filename = '".$result['filename']."') OR "; } Read String Operators.
-
A cookie has both a domain and a path. If you set a cookie's domain to "domain.com", you will also see it on "sub.domain.com" but only if its path matches the URL. So set the domain as ".mydomain.com" and the path as "/", which means any path on any subdomain. They're two different things that work together.
-
If you assign a cookie with the domain .domain.com (or just domain.com) it should be sent to any subdomain as well. Just make sure to set the path as / or something that fits all subdomains you want. See session_set_cookie_params.
-
Something Wrong with My Logic? - User IDs or Coordinates?
dcro2 replied to Thauwa's topic in PHP Coding Help
Well, random numbers sound fine to me honestly. //somewhat pseudo code do { $x = rand(0,200); $y = rand(0,200); } while ( num_rows "SELECT * FROM users WHERE x='$x' AND y='$y'" > 0 ) query "INSERT INTO users (x,y) VALUES ('$x', '$y')" As for the distance sorting, I would guess something like $userX = 123; $userY = 123; query "SELECT ABS( SQRT( POW($userX - x, 2) + POW($userY - y, 2) ) ) as distance FROM users SORT BY distance ASC"; Don't know if that's actually valid SQL but it's a start. -
Fatal error: Cannot redeclare dsCrypt() in wordpress
dcro2 replied to nikhilnaik's topic in PHP Coding Help
Current version of that theme is 2.0: http://www.wpzoom.com/themes/cadabrapress/ I'm sure you bought it, so go ahead and update it. -
e-mailing exported sql tables in excel file format
dcro2 replied to agon024's topic in PHP Coding Help
Instead of using echo, store everything in a variable and then use a mailer class like PHPMailer or SwiftMailer to send that as an attachment. $xlsFile = ""; //insert your code //using SwiftMailer as an example require_once 'swiftmailer/lib/swift_required.php'; $attachment = Swift_Attachment::newInstance($xlsFile, 'file.xls', 'application/vnd.ms-excel'); $transport = Swift_MailTransport::newInstance(); //using php's mail() $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance('Wonderful Subject') ->setFrom(array('[email protected]' => 'John Doe')) ->setTo(array('[email protected]', '[email protected]' => 'A name')) ->setBody('Here is the message itself') ->attach($attachment); $result = $mailer->send($message); //append to variable instead of echo function xlsBOF() { global $xlsFile; $xlsFile .= pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); } //repeat for other functions Get rid of all the header() calls if you want the browser to stop prompting you to download it. -
The hidden inputs you have for each result all have the same names, so every time you echo another result their values get overwritten. You should append the id of each result to the name of each hidden field, like so: '<td><input type="hidden" value="'.$result1['item_name'].'" name="item_name_'.$result1['id'].'">'.$result1['item_name'].'</td>' That way when you access them through $_POST, you have to also append the id in order to access them: $id = $_POST['test_id']; $_POST["item_name_$id"]; I would not even include any field other than the id in your form, other than for display purposes. I would fetch the corresponding test from the database based on the ID alone, and check if it is actually available. Any inputs on your page, hidden or not, can be modified so you shouldn't trust them so much.
-
First you have to make that <select> part of a form. <form action="displaycity.php" name="selectCity" method="get"> <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'cities_wrdp1'; mysql_select_db($dbname); $sql = "SELECT DISTINCT City FROM PBM"; $result = mysql_query($sql); ?> <select name='City' onchange="document.forms['selectCity'].submit()"> <?php while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['City'] . "'>" . $row['City'] . "</option>"; } ?> </select> </form> Then, in displaycity.php: <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'cities_wrdp1'; mysql_select_db($dbname); $query = "SELECT * FROM people WHERE city = '".mysql_real_escape_string($_GET['City'])."'"; $result = mysql_query($query); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } ?> <table> <tr><th>First Name</th><th>Last Name</th><th>Street</th><th>City</th><th>Zip Code</th></tr> <?php while($row = mysql_fetch_array($result)) { echo "<tr>" echo "<td>".$row['f_name']."</td>\n"; echo "<td>".$row['s_name']."</td>\n"; echo "<td>".$row['street']."</td>\n"; echo "<td>".$row['city']."</td>\n"; echo "<td>".$row['zip_code']."</td>\n"; echo "</tr>"; } ?> </table>
-
You have your information in flash. I'm not really sure how you would schedule that to run in order to check if the dates match, but if you can get it to call a php script, there's lots of mailer classes you can use like SwiftMailer or PHPMailer or you can build your own email and send it using the mail function built into PHP.
-
The problem you're having is that you end the row (</tr>) in the third section of your while loop but never start another row, so the columns after the first three don't have their own row and the display is messed up. In any case, I think you should be doing something like this instead to not have to repeat your code three times: <tr> <?php $hotelsPerRow = 3; $i = 1; $qry_hotel = mysql_query("select * from hotel where statiune='$stati'"); while($hotel_rs=mysql_fetch_array($qry_hotel)) { ?> <td align="left" width="33%" valign="middle"> <table width="100%" border="0"> <tr> <td colspan="2" align="center"><img src="admincp/photos/hotel/<?php echo $hotel_rs['img1']; ?>" width="200" height="150"></td> </tr> <tr> <td width="118" height="28" align="right"> </td> <td width="80" align="center" valign="middle" background="imgs/prcbg.jpg" class="sidebar"><span class="style2"> <?php echo $hotel_rs['p_label']." "; ?> </span></td> </tr> <tr> <td colspan="2" align="left"><span class="tour"><a href="hotel.php?ID=<?=$hotel_rs['ID'];?>" class="tour"> <?php echo $hotel_rs['nume_hotel']; ?> </a></span></td> </tr> </table> </td> <?php if($i % $hotelsPerRow == 0) echo "</tr>\n<tr>"; $i++; } </tr> The modulus (%) operator checks the remainder when you divide by something, so when $i is divisible by $hotelsPerRow (when the remainder is zero), you start a new row. Also, try not to use the short php syntax (<? or <?=) because they're not recommended and if you change hosts they might not support it.
-
Can we have some example output? My brain hurts from all the nested tables.
-
Need Coding Help: webform app data/upload capture to email
dcro2 replied to JStyl's topic in PHP Coding Help
Can you post what pt_register() does? Also, use or around your code. -
Try visiting the source of the image directly. Most likely, one of your error outputs in images.php is making a corrupt image. Since the browser is expecting to display an image inside the <img>, it just thinks it's broken. So, again, view the source of link.php in your browser and visit whatever it has output as the src of the image. For example, 'images.php?id=123'. Then you'll be able to see any errors your script encountered.
-
Arrays can have numeric and alphanumerical keys, so they can be [1], [2], ['08'] or ['alphabet']. Arrays can be simply declared by setting one of its indices. It can be nicer to look at than say, $data = array('title' => "My Bog Title", 'heading' => "My Bog Heading");. Am I missing something about your question? http://www.php.net/manual/en/language.types.array.php PS: Bog?
-
Maybe you can make whatever's in that file into a function instead, then you can call something like xboxapi_get($gamertag);. Use $gamertag in your code instead of $_GET['gamertag'].
-
Nobody's said anything about permissions, so I'm just going to ask. Are you sure the 'inventory_images' directory exists in the same place as this php file and you have write permissions to it? Add this to your file and post what you get: echo "does dir exist? "; var_dump(file_exists('./inventory_images')); echo "<br>\nis dir writable? "; var_dump(is_writable('./inventory_images')); echo "<br>\n";
-
That's pretty much the only way to "redirect" with POST data, unfortunately. But they have an option to send your data through GET instead of POST, so you can redirect to that url instead. See page 16 of their API documentation. On page 17 there's also something that might be a way to send all your data including credit card number to the processor without leaving your site, but I'd be weary of doing that if your site has no SSL. Here's the most important part from the PDF:
-
Put if(isset($message)) echo $message; where the echo was before, right above the form. <?php //here ?> <br /> <form method="post"> <p>Username
-
I was actually trying a function like that I found, but on lighttpd it still seems to use a lot of memory if the file is big (probably actually because of php-fastcgi), and it never releases it. On apache it seems to work fine though, so here: function readfile_chunked ($filename) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); print $buffer; ob_flush(); flush(); } return fclose($handle); } Try using that instead of fpassthru().
-
It's probably because you're using readfile() and php is exceeding its memory limit. If you use apache and it has mod_xsendfile or lighttpd then you can just set the X-Sendfile header.
-
Then.. what you could do is: 1. Make the form submit to your own .php validator 2. If everything checks out, output a form with all hidden fields containing the same data that was submitted, with the action set to the payment processor page. 3. Include some javascript in the page to submit the form automatically. Include a visible submit button in case Javascript isn't enabled. Unfortunately, that means it's possible to modify the form before submitting. But unless you can output all the html returned by the payment processor and not have any problems with cookies, and all images/forms still work, then I can't think of another option. Unless you want to take on handling transactions between your visitor and your payment processor by yourself.
-
Ok, so I'm assuming you wrote a PHP script to set the header to force-download and then send the file to the browser? Can you post your code?
-
I'm sorry, are you talking about upload or download? Are you uploading files to your website or is your PHP script downloading a file?