Jump to content

Scotty2024

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by Scotty2024

  1. Bump again. Sorry I don't know how to put the above into a json array or set up the curl headers.
  2. Could you please show me an example? For example, in the documentations first part, how would you encode the following into a json array? What would the cURL look like with the necessary headers? Thanks.
  3. Does anyone know how to use Google Flight RPC or how to post a json array to it? The only documentation I've found for it is here. It shows the responses and part of the requests. I'm not sure how to build and post a json array using PHP. Any ideas or examples how?
  4. I'm not strong with left/right join. So would it be something like this: select name from table1 left join on table2 on table1.id = table2.userID
  5. Try something like this: <html> <head> <title></title> </head> <body> <?PHP session_start(); $cart = $_SESSION['cart']; $action = $_GET['action']; //test $action echo 'Value of action: ' . $action; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; } ?> <p><?=$fldname;?> <a href="<?=$_SERVER['PHP_SELF'];?>??viewdetail=<?=$nameid;?>&action=add&id=<?=$row['idinfo'];?>">Add to report</a></p> </body> </html>
  6. You could do it with sessions too. To create a cookie use setcookie. For example: setcookie(name, value, expire, path, domain); Then get the cookies data with $_COOKIE[] It can be deleted by setting it to expire. For example setcookie("foo", "", time()-3600); w3schools has a tutorial called What is a cookie?. Both sessions and cookies will only temporarily keep track of the information for you. A database will keep track of it for as long as you want.
  7. If you know the string you want to check for, use a regular expression with preg_match.
  8. Move the add function from the cart.php file to the product file or wherever the Add to report link is. Then on click execute the function when the page reloads. You could also do it with AJAX without a page refresh. Switching to ajax would be more than a small tweak though.
  9. Have a look at fopen, fread, and fclose. These will allow you to read in information from the text file.
  10. You could set a cookie with past video IDs viewed. Or keep track of each video viewed by your users in a database. Do a check against the cookie/database before the video is loaded and if a match is found, send to a new random video.
  11. Hello. I'm trying to create a query to join on two tables. Table1 has id and name. Table2 has userID and itemID. Table1 id and table2 userID are the same. For a specific itemID I want to select all names from table1 where the userID in table2 does not exists. For example, here is some test data. Table1 1 Bill 2 Bob 3 Joe Table2 1 1 2 1 3 2 If I wanted to get all names where the userID wasn't listed for itemID 1, it would return Joe. Similarly if I wanted to get all names where the userID wasn't listed for itemID 2, it would return Bob and Joe. Finally, if I wanted to get all names where the itemID was not equal to 1 or 2, it would return Bill, Bob, and Joe. How do I join the two tables to do this? Thanks.
  12. Hello, Is there a way to track how much each adsense ad is generating. I have someone that helps contribute content to my website. I would like to track all the ads that are clicked in the content that this other person writes. That way, as an incentive, they will get a higher percentage of the revenue from those particular ads. It will give them an incentive to create more/better content also. I know its possible to generate different types of ads but I don't think its possible to see which ad is clicked or to track them. Well, at least I didn't see a way. So that brings me here to ask my question. Thanks for the help.
  13. if(isset($_POST['submit'])) { if(isset($_POST['checkbox'])) { //proceed } else { $checkBoxFlag = true; } } //at your form or wherever if($checkBoxFlag) { ?> <script type="text/javascript"> alert("You must check the checkbox"); </script> <?PHP } //form code here
  14. Would love to change the host but can't. Anyone else have any suggestions. My tip: stay away from 1and1.com
  15. if(isset($_POST['submit'])) { if(isset($_POST['checkbox'])) { //proceed } else { $checkBoxFlag = true; } } //at your form or wherever if($checkBoxFlag) { echo 'You must check the checkbox'; } //form code here
  16. Is there another method? For some reason the resizing script hangs up on the imagecreatefromjpeg() (or gif, png) call for images larger than 400-500 KB. I have determined that the hang is due to my host (1and1.com) because I have tried the exact script on another server and it worked fine. Is there another method without a call to imagecreatefromjpeg()? Thanks
  17. How can I resize an image? I would like to take an image that I have in a folder and resize it to make a thumbnail of it. Then save the thumbnail in the same folder as the original image. The image has already been uploaded and is saved in a folder. Is it possible to resize it for a thumbnail?
  18. I tried a simple upload script without the resizing just to see if I could upload images larger than 400 KB. The script below works, however I don't know how to resize the image which is required for my application. Can anyone help me adapt this script below to resize the image? <?php if ($_REQUEST[completed] == 1) { $newname = uniqid("whc").".jpg"; move_uploaded_file($_FILES['mailfile']['tmp_name'], "pictures/$newname"); } ?> <html> <head><title>Upload page</title></head> <body><h1>Image Uploader</h1> <?php if ($_REQUEST[completed] != 1) { ?> <b>Please upload an image</b><br> <form enctype=multipart/form-data method=post> <input type=hidden name=MAX_FILE_SIZE value=1500000> <input type=hidden name=completed value=1> Picture: <input type=file name=mailfile><input type=submit></form> <?php } else { ?> <b>Uploaded!</b> <?php } ?> </body> </html>
  19. Here is an update. I am pretty sure that the script works for all images. I tried it on a different server with the same images and everything worked as it should. I now believe that it is the fault of the server. This script is failing on 1and1.com servers (I am not a fan of this company). I know that the GD Graphics Library is required for this script. To make sure the library is installed I tried phpinfo(); (in info.php) but that also fails on this server. For some reason it pulls my css style sheet, header graphic and required navigation php file. I have no clue why or how it gets all that when all I have is <?PHP phpinfo(); ?> in the info.php file. Can anyone tell me if 1and1.com has the GD graphics library installed and what version? Also, why does this script fail for large images (~400 KB or larger) on 1and1.com servers and not other servers? 1and1 is definitely frustrating! Better yet, can anyone tell me how to upload and resizes images a different way that 1and1 will like? Thanks for any help!
  20. For Input the Coordinates, the <form> tag needs to encompass the entire form. Try this <form name="editlevels" method="post" action="powers/levelgen_admin.php"> <td><INPUT TYPE="text" NAME="editcoords" SIZE="30"></td> <td> <p align="center"> <input type="submit" value="Edit a Level"> </p></td> </form> To pull the info from the above form, use $_POST like this <?PHP $c = $_POST['editcoords']; ?> You are editting <?PHP echo $c; ?>.<br><br> <form action="levedit.php" method="post"> <table border=0> <tr> <td> TITLE:<br /> <input type="text" name="title" value="<?PHP echo $title; ?>"> <br /><br /> CURRENT:<br /> <textarea name="descript" rows="10" cols="50"><?PHP echo $descript; ?></textarea> <br /><br /> ALTERNATE:<br /> <textarea name="alt" rows="10" cols="50"><?PHP echo $alt; ?></textarea> </td> <td valign=top width=30%> <table width="100%" style="text-align:center"> <tr> <td width=33%> </td> <td width=33%> NORTH:<br /> <select name="n"> <option value="0">No</option> <option value="1" <?PHP if ($n == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $n; ?> </td> <td width=33%> UP:<br /> <select name="u"> <option value="0">No</option> <option value="1" <?PHP if ($u == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $u; ?> </td> </tr> </table> <br /> <table width="100%" style="text-align:center"> <tr> <td width="50%"> WEST:<br /> <select name="w"> <option value="0">No</option> <option value="1" <?PHP if ($w == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $w; ?> </td> <td width=50%> EAST:<br /> <select name="e"> <option value="0">No</option> <option value="1" <?PHP if ($e == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $e; ?> </td> </tr> </table> <br /> <table width="100%" style="text-align:center"> <tr> <td width="33%"> DOWN:<br /> <select name="d"> <option value="0">No</option> <option value="1" <?PHP if ($d == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $n; ?> </td> <td width=33%> SOUTH:<br /> <select name="s"> <option value="0">No</option> <option value="1" <?PHP if ($s == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $u; ?> </td> <td width=33%> </td> </tr> </table> </td> </tr> <tr> <td colspan="2"> <input type="hidden" name="p" value="<?PHP echo $p; ?>"><input type="hidden" name="co" value="<?PHP echo $c; ?>"><input type="hidden" name="username" value="<?PHP echo $username; ?>"><input type="hidden" name="password" value="<?PHP echo $password; ?>"><input type="hidden" name="no" value="<?PHP echo $no; ?>"><input type="submit" value="Edit Level"> <input type="reset" value="Reset"> </td> </tr> </table> </form>
  21. I am having problems with imagecreatefromjpeg() hanging up while uploading files ~400 KB or larger. Am I doing anything wrong? Here is an example for jpg files: upload form <form action="upload.php" method="post" enctype="multipart/form-data"> Picture: <input name="userfile" type="file" id="userfile"> <br /> <input type="submit" name="uploadPic" value="Upload" /> </form> upload.php if(isset($_POST['uploadPic'])) { $image = $_FILES['userfile']; //assuming user did upload an image. error checking not shown. switch($image['type']) { case "image/pjpeg": case "image/jpg": case "image/jpeg": jpg_processing($image); break; //case gif and png... } function jpg_processing($picture) { $fileName = $picture['name']; $tmpName = $picture['tmp_name']; $fileSize = $picture['size']; $fileType = $picture['type']; $size = getimagesize($tmpName); //Resize image to correct size if($size[0] > $size[1]) //width > height { if($size[0] > 604) { $h_max = ($size[1] * 604)/$size[0]; $w_max = 604; } else { $h_max = $size[1]; $w_max = $size[0]; } } else if($size[0] < $size[1]) { if($size[1] > 604) { $w_max = ($size[0] * 604)/$size[1]; $h_max = 604; } else { $h_max = $size[1]; $w_max = $size[0]; } } else if($size[0] == $size[1]) { if($size[0] > 604 && $size[1] > 604) { $h_max = 604; $w_max = 604; } else { $h_max = $size[1]; $w_max = $size[0]; } } $w = $size[0]; $h = $size[1]; $x_ratio = $w_max/$w; $y_ratio = $h_max/$h; if ($w <= $w_max && $h <= $h_max) { $w_tn=$w; $h_tn=$h; } else if (($x_ratio * $h) < $h_max) { $h_tn=ceil($x_ratio*$h); $w_tn=$w_max; } else { $w_tn = ceil($y_ratio * $w); $h_tn= $h_max; } //done with resizing $src = imagecreatefromjpeg($tmpName); //THIS LINE hangs! Doesn't make it past here. $dst = imagecreatetruecolor ($w_tn, $h_tn); imagecopyresized($dst, $src, 0, 0, 0, 0, $w_tn, $h_tn, $w,$h); imageinterlace($dst, 1); $out_file= '/pictures/'. mt_rand() . '.jpg'; $location = 'http://website.com' . $out_file; imagejpeg ($dst, $out_file, 100); } I don't know why it hangs up on imagecreatefromjpeg(). The browser is blank and simply shows "Done" in the status bar. I have read that this happens if the image doesn't have an EOF tag. I have tried several different images and it still hangs. However, if I upload small images like ~100 KB or less, it works. Do I have an error in my code I am over loooking? Thanks!
  22. Thanks again Alex. I got both methods to work!
  23. Hello AlexWD and PFMaBiSmAd. Alex, I was able to get your method to work! Thanks! PFM, I couldn't get readfile() to work. Do I switch readfile() with imagepng() and add ob_clean() flush() in Alex's example? And can I still use <img src="retrieve.php?id=<?PHP echo picID; ?>"> in display.php to retrieve the image? Thanks!
×
×
  • 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.