Jump to content

jdock1

Members
  • Posts

    210
  • Joined

  • Last visited

    Never

Everything posted by jdock1

  1. Thanks. I tried that and it didnt work, still giving me the query error. Anybody else no how to do this? I would love to know how to do this so I can complete this script Ive been working on for a while. There has got to be a way to do this, right!?
  2. What I mean by dynamic is say I created a function to generate a random code. I put it in a variable named $key. I make a form with a hidden input type with the name and value of $key. When the form posts, it generates the table name to whatever $key is. Because I tried something like this & its not querying. Heres my code: <?php $dbc = mysqli_connect('localhost', 'cpacrop_todo', 'pass', 'cpacrop_todo') or die('Failed to connect to database!'); function make_key($num_chars) { if ((is_numeric($num_chars)) && ($num_chars > 0) && (! is_null($num_chars))) { $key = ''; $accepted_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; //seed srand(((int)((double)microtime()*1000003)) ); for ($i=0; $i<=$num_chars; $i++) { $random_number = rand(0, (strlen($accepted_chars) -1)); $key .= $accepted_chars[$random_number] ; } return $key; } } $key = make_key(6); ?> <form action="" method="post"> <input type="hidden" name="<?php echo "$key"; ?>" /> <input type="submit" name="submit" value="Submit" /> </form> <?php if ($_POST['submit'] == "Submit") { $query = "CREATE TABLE `$key` ( `id` INT AUTO_INCREMENT, `title` VARCHAR(35), `description` VARCHAR(365) );"; mysqli_query($dbc,$query) or die('Unable to query database.'); echo "Success"; } ?> If this is possible, what am I doing wrong? Thanks!
  3. I was thinking of that, the only problem is Idk where to start with that... Its frustrating I cant think of anyway to do it at all. Can you give a few code examples?
  4. Im displaying the results of a database by using a while loop... so Im trying to figure out how to delete some entries from the datbase. What I wanted to do is add a button in each result that will have the value "delete"... but I cant figure out how to do this. Im kinda new to mysql. I just want it so when I click the button the result will get deleted from the database. I did some research on this but I cant really grasp the examples. Can anybody help me out with this one? Thanks!
  5. So far I just want a basic structure, a database with one table with two values, yes or no. yes would be for email validated, no for email not validated. i just want it so when a user signs up, it sends a unique link to their email to validate their email. I cant even think right now, ive been coding all day and cant even begin to think of how to start this. anybody got any ideas? thanks
  6. goodguybadguy.net they can tell when you enter an email address that hasnt been registered yet. how the hell are they doing this? does gmail or yahoo have some sort of database they allow access to for this?
  7. i was looking at that, i tried implementing it but it gave me a query error. This is what I had, what did I do wrong? $query = "INSERT INTO gencode (generated) VALUES ('(htmlentities)$code'))";
  8. Im inserting HTML into a database, and then outputting it on a PHP page. Its an iframe code, so when I output it, it shows the iframe. I need it to just display the HTML code. How can I do this? I thought it would be something simple but I can find anyway to do it. Help very appreciated!! Thanks
  9. Ive been trying to make a simple uploader script for a friend of mines website im working on, but its just not working and I know im doing everything right! Here is the code: <?php $target_path = "http://adiscountsignco.com/admin/uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> So, I created in the admin directory both a directory name "tmp" and a directory named "uploads" , however its still not working? Its just giving me the "there was an error uploading the file, please try again!" error in the else statement. I just dont get it, did i miss something? Im new at working with $_file, im not a total noob at php but ive never worked with this before and it is really pissing me off! Thanks!!!!
  10. None of this is working. Ok, to make it simpler... how can I style a pure PHP page? Im trying to use the styles for the variable $errormsg I created that is printed through die()
  11. Ok nevermind. Seems like I broke the script by doing that. Damnit!!!???
  12. Oh okay I got it, kind of. I got it to apply the style and echo the html tags. Its pretty sloppy tho. Its like this; $html = "<html>"; $head = "<head>"; $endhead = "</head>"; $endhtml = "</html>"; $style = "<style>div.errors { border: 1px dashed #660000; background: #fee; color: #660000; }</style>"; ... // blah blah blah if($current_time - $blocked_time > 3600*24) //24 hours past { $str_sql = "delete from ".$db_table." where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } else { echo "$html"; echo "$head"; echo "$style"; echo "$endhead"; die ("<div align='center' class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div>"); echo "$endhtml"; } } Is there an easier, cleaner way to do this??
  13. How can I add html tags in php as a variable? For example, for some reason my code gives me a header error if I use html before the php tags. I just need to add the style in there. I was wondering how I could add a style of any html tag within php as a variable?? Like I was thinking like <?php $style = "<style> div.error { border: 1px dashed #660000; background: #fee; color: #660000; } </style>"; echo $style; ?> But that would probably just print out the code... how can I make it so it wont print out on screen and I can actually use the style? Sorry for the noob question... im kind of an intermeddiate php programmer but the noobs questions still seem to never go away!
  14. Ah I got it. Thanks for your replies. There was HTML before the php tags. Gets me everytime. I still dont understand it, most of the time I can get away with that but for some reason when I use cookies or includes it dont let me do that.
  15. I hate header errors... I can never figure them out, im getting this error; Warning: Cannot modify header information - headers already sent by (output started at /home/damnpeti/public_html/restrict2.php:6) in /home/damnpeti/public_html/restrict2.php on line 62 Code: <?php $testDB = mysql_connect('localhost', $db_user, $db_pwd); mysql_select_db ($db_name); if (!$testDB) { die('Could not connect: ' . mysql_error()); } $surfer_ip = $_SERVER["REMOTE_ADDR"]; $str_sql = "select * from ".$db_table." where ipaddress='".$surfer_ip."'"; $result = mysql_query($str_sql); if ($row = mysql_fetch_assoc($result)) { $blocked_time = strtotime($row['blocked_time']); if($blocked_time != 0) { $current_time = time(); if($current_time - $blocked_time > 3600*24) //24 hours past { $str_sql = "delete from ".$db_table." where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } else { die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } else { if($row['surf_index'] < 2) { $str_sql = "update ".$db_table." set surf_index=surf_index+1 where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); } else { $str_sql = "update ".$db_table." set blocked_time='".date ("Y-m-d H:i:s")."' where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } } else { $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } if(!isset($_COOKIE['surf_no'])) setCookie('surf_no', '1'); else setCookie('surf_no', $_COOKIE['surf_no']+1); if ($_COOKIE['surf_no'] > 2) die("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); include 'http://damnitpetitions.com/cut/index3.php'; ?> Line 62 is if ($_COOKIE['surf_no'] > 2) I know it has something to do with the cookie... but Idk? I need the include there. If there include isnt where its at, the script is worthless.
  16. Well the way everything is set up I need to use die it makes it easier for me. This script resticts access to a page after being viewed 3 times... it saves the surfers IP in a database and matches it ...when the surfer gets the error message, it exits the script... im using an include file for the content on the page. Idk, it just makes it easier for me. But how would I apply the html in it? Like whats the structure of it? Thanks for your reply
  17. I need to use my error message div within die()... but i dont know if I can do this.. Im not good with escaping with quatations for example, I got else { die ("Your ip has been blocked. Time till unblock:".($current_time - $blocked_time)); } I need to put a div in there for the error style: else { die ("<div class='error'>Your ip has been blocked. Time till unblock:".($current_time - $blocked_time));</div> } But I know that will just cause a bunch of errors. First of all is it even possible? Thanks for all the help I love this site. Its kind of embarassing the stupid shit I ask but Im just horrible with putting html into php. What confuses me is using double qoutes n single quotes and just quotes in general I just cant grasp it!
  18. Thanks bud, I just didnt really know how to implement that... I cant believe I didnt think of that earlier. I got it working by storing the IP address in a database and matching it
  19. Can anyone help? Or atleast get me started up atleast tell me how I could do this? What functions etc..?? I really need to do this
  20. For one of my javascript/php scripts , I have a demo up & I do not want people taking advantage of the demo and using it all the time. How could I make it so the user can only access the page 3 times in a 24 hour period?? I couldnt think of anything
  21. Whats blocking what? Yeah same here, im far from an expert in server tech
  22. Nobody can figure this out? Im so pissed about this idk wtf is wrong theres absolutely no reason why it should be doing that !
  23. I have no problem using my script on another server, but now when I uploaded it to my other server, its telling me that the area is forbidden. The index file works, but when I crop the frame, it generates the iframe code, which is hosted on a php page. The php page is giving me the forbidden error. I tried all types of different permissions, but it still doesnt work. It is the exact same code as used on my other server. Please check this out for me, go to http://damnitpetitions.com/cut/index.php & enter a url, just use phpfreaks.com as an example. You will see in the box below it loads the page. Drag & drop your cursor to crop an iframe. Below that you will see a textarea with the generated code. Below that, you will see the iframe. It will say its forbidden. For example the generated code <iframe src="http://damnitpetitions.com/cut/out.php?url=http%3A//phpfreaks.com&height=400&width=600&left=12&top=33.600006103515625" style="height: 115px; width: 324px"></iframe> & the direct link http://damnitpetitions.com/cut/out.php?url=http%3A//phpfreaks.com&height=400&width=600&left=12&top=33.600006103515625 Now, go to the script on my other server, WITH THE SAME CODE http://174.121.237.117/cut/test.php use phpfreaks as an example again. Direct link, no forbidden error: http://174.121.237.117/cut/out.php?url=http%3A//phpfreaks.com&height=400&width=600&left=25&top=32.600006103515625 All the permissions are set the exact same on each server. For the IP, its a hostgator VPS. For the site that im having trouble with, its on a shared hostgator server. My only guess is that it could be some kind of different PHP configuration?? It just makes no sense to me, & I am getting really frustrated! Please help!! BTW - Use firefox for this script. I have not tested it in any other browser. Also, I am the developer of this shitty script. This is my code, so I know the ins & outs. Thanks!!!
  24. Currently I cant send you source code, but it'll be available after few modification and then this code will be open source and available for download. Regards, Ivan Cool. I am definitely interested, let me know whenever its available.
×
×
  • 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.