Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

Everything posted by WebStyles

  1. Again, it seems xc0n was NOT paying attention to the code I gave him. There are no quotes in my examples.
  2. $q is a variable with the select statement. when you call it in $r = mysql_fetch_assoc($q); it gets evaluated, so if there's an error in $q, it will only show up when you try to use that variable in $r = mysql_fetch_assoc($q);
  3. you need to pay attention... I'm trying to help, but if you're not going to read what I write, you are just wasting your (and my) time. I have said this before: where you have: `validate_ip` = '$user_ip' limit 1 should be `ips` = '$user_ip' limit 1 since your database does not have a field called `validate_ip`
  4. since you've made changes and not posted your code again, I have no idea what to say. Post the code please.
  5. Either you're not explaining properly or this is a simple html question. you want a simple dropdown boy saying price, name or size? <select name="whatever"> <option value="price">price</option> <option value="name">name</option> <option value="size">size</option> </select>
  6. is you database table actually called 'table' ? you need to correct that.
  7. Nodral, you're wrong. the string is enclosed in double quotes, so: $q = mysql_query("select `id` from `allowed_ips` where `validate_ip` = '$user_ip' limit 1"); will work fine, your example will not.
  8. well, if you created a table with id, ips, then you need to use: select `id` from `validate_ips` where `ips` = '$userIP' also, IP addresses can only be XXX.XXX.XXX.XXX (i.e. 15 characters in length) why is your database field varchar 200 ?
  9. something like: table points: userID, points on login, get user's available points. only show buy button when price is lower than available points.
  10. instead of this: $conn = mysql_connect("localhost", "user name", "database pass")or die("cannot connect to database"); mysql_select_db("database name")or die("cannot select DB"); try this: $conn = mysql_connect("localhost", "user name", "database pass")or die("cannot connect to database"); mysql_select_db("database name",$conn)or die("cannot select DB");
  11. You don't need to encrypt IP addresses, they will not be seen by anyone unless you specifically output them to a page. but, if you still feel you should, md5 is easy to use: $encryptedIP = md5($_SERVER['REMOTE_ADDR']);
  12. Nodral's example should work too, but if each user has only ONE ip address, what would be the point of reading ALL of them out of the database and then checking if it's valid, when you can check directly in the database for a single ip? what would happen if you had several thousand addresses in the database? also, if you only have a bunch full, that don't need upating too often, why not just put the array in a separate file and use include_once() ?
  13. with something like.... (assuming you have a table like id,ipAddress) $usersIP = $_SERVER['REMOTE_ADDR']; $conn = DatabaseConnection(); // your database connection function $q = mysql_query("select `id` from `allowedIPS` where `ipAddress` = '$usersIP' limit 1",$conn); $r = mysql_fetch_assoc($q); @mysql_close($conn); if(!empty($r)){ // ALLOW }else{ // DENY } P.S. this is a pretty basic example, but it should work.
  14. sorry, typo. there's a closing parentisis missing, should be: if(in_array($userIP,$allowedIPS)){ // ALLOW }else{ // DENY }
  15. Not really a question of taste. It's a question of speed/necessity for me. If you use single quotes, PHP will not try to interpret variables inside them, therefore it will process faster. I normally use single quotes for most everything, except when I specifically need special interpretations, like when sending an email, if I need to insert a line break (\n) this will only be properly interpreted as a line break if it's withing double quotes.
  16. I'm not sure what you mean, you want to check the users IP and decide if it's allowed to do something? try something like: // list all allowed IP's $allowedIPS = array('192.168.1.1','192.168.1.2'); // get current user's IP $userIP = $_SERVER['REMOTE_ADDR']; // check if it's in ALLOWED list if(in_array($userIP,$allowedIPS){ // ALLOW }else{ // DENY } hope this helps
  17. I still don't get what you mean, you want to have name, size and price in the same dropdown box? like JOHNNY XL $5,00 PETER XXL $7,50 ??? And what is the value you would like each field to POST through your form?
  18. FOUND IT. //open image **************************************** $image = imagecreatefrompng("client_piece".$i.".png"); // open piece with pixel mapping $piece = imagecreatefrompng("piece".$i.".png"); // try merging pixel by pixel and list all colors: $fuschia = imagecolorallocate($piece,255,0,255); for($x=0;$x<$width[$i];$x++){ for($y=0;$y<$height[$i];$y++){ if(imagecolorat($piece,$x,$y)!=$fuschia){ imagecopy($image,$piece,$x,$y,$x,$y,1,1); } } } // Grab pink color just to be sure: $pink = imagecolorat($image,0,0); imagecolortransparent($image,$pink); // write to disk imagepng($image,"client_piece".$i.".png"); // free memory imagedestroy($image); what that is doing is that my template image has bright pink representing the transparency (imagecolorat($image,0,0);) grabs that color and uses it as a reference to set the new image's alpha channel. imagecolortransparent($image,$pink); hope this helps
  19. I have done that before, a very long time ago, so I can't remember the specifics. I do remember that I had to have a png file with just the circle and the transparency to use as a template, and then I would open the jpeg, merge it with the png and save again. I'll have a look around my hard drives to see if I can find my code.
  20. you wont be able to pull out all the project ids if you don't remove LIMIT 1 from your sql query.
  21. yeah, if it's working, seems fine for what you need. just a little note: where you have this: $result = mysql_query("SELECT * FROM members WHERE club='fen' ORDER BY `members`.`id` ASC"); you don't realli need to specify the table in the ORDER BY part, since you're only selecting from one table, so you could just write this: $result = mysql_query("SELECT * FROM `members` WHERE club='fen' ORDER BY `id` ASC"); also ASC is the default value, so you don't need it either: $result = mysql_query("SELECT * FROM `members` WHERE club='fen' ORDER BY `id`"); and since you used back ticks for the id and members fields, keep it coherent and also use them in club: $result = mysql_query("SELECT * FROM `members` WHERE `club` = 'fen' ORDER BY `id`"); (even though some people may not agree with their use, back ticks may be helpful in the future, if you accidentally use a mysql reserved word for a field name and cannot figure out why it's not working) Now, if you want to improve on it a bit, check out mysql_real_escape_string manual, since you're sending a field value over an url, you may need to protect yourself against SQL Injection attacks. Glad to see you got it working!
  22. I haven't looked at your code, but it could be a folder permissions problem (maybe some update on the server changed the permissions?)
  23. @jcbones yeah, maybe not... but it could still work if the project names are unique or something.
×
×
  • 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.