Jump to content

Mudsaf

Members
  • Content Count

    456
  • Joined

  • Last visited

Community Reputation

16 Good

About Mudsaf

  • Rank
    Member
  • Birthday 08/29/1994

Previous Fields

  • Languages
    php,css,javascript,jquery,mysql,html

Contact Methods

  • MSN
    Mudsaf@hotmail.com
  • Website URL
    http://www.mudsaf.com/
  • Skype
    Mudsaf

Profile Information

  • Location
    Finland
  • Interests
    Coffee & Gaming

Recent Profile Visitors

5,884 profile views
  1. Where have you defined variable called $id, for sure I cannot see one in this code.
  2. You can store wherever you want as long as you know the path you store them. If you want to store outside of www directory then you need to use php readfile() and store mime_types, but that gets bit more complex.
  3. Check the item_id where you are getting the error. You are trying to create it as primary key, but you only have column called id. As justsomeguy told you have to pay attention to details. Check the underlined areas, also you are missing a comma before primary key. Below working example. CREATE TABLE IF NOT EXISTS images ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, img VARCHAR(20) NOT NULL, PRIMARY KEY (id) ); INSERT INTO images (img) VALUES ("testx");
  4. What you are trying to do isn't going to work with the table you just created. You need to make 3 more columns to your database table to be able to fill the rest of information in your query. Example scenario account information id int auto_increment primary key | username varchar(50) | password varchar(128) | email (varchar150) unique So lets pretend that the table we created with the "create table" query. So we wound have to do insert query like below. insert into accounts (username,password,email) values (value1,value2,value3)
  5. It was just example text that you could insert to the database. (Whatever you want to insert into img column, usually the filepath+name as you mentioned)
  6. As for SQL try this CREATE TABLE IF NOT EXISTS images ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, img VARCHAR(20) NOT NULL ) INSERT INTO images (img) VALUES ("imageurl")
  7. After move_uploaded_file just do simple sql query that adds the information to database. You already have all the available information ready. If you only have 2 columns on database, you only need the image name stored, since id is auto_integer primary key (so its auto generated). What kind of issues are you having with your code? More about file upload: https://www.w3schools.com/php/php_file_upload.asp More about sql insert: https://www.w3schools.com/php/php_mysql_insert.asp
  8. Not sure what kind of sorcery is this, but it works now. Thank you!
  9. Original string returns 2 unicode blocks (straight from $_GET): �(194) �(164). Where ¤ is.
  10. The unicode block symbol returned value of 194 via ord() function, got any idea what might be the cause to create that unicode block? Source code of tester below, string too. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> #kool { width:800px; border:groove; margin:0 auto; padding:25px; } .mid { margin:0 auto; max-width:800px; text-align:centeR; margin-top:10px; } #preg_input { width:300px; } </style> </head> <body> <?php /* Test preg_replace function */ // #%&()=@£\$€\[\]_\-,.:? $basic = "A-Za-Z0-9"; $preg_pattern = "/[^A-Za-z0-9!\"#%£&()=@\s]/"; $func_preg_replace = preg_replace($preg_pattern,"",$_GET['preg']); if (isset($_GET['preg'])) { echo "<div id='kool'>"; echo "<b>Original string: </b> " . $_GET['preg']; echo "<hr>"; echo "<b>Preg pattern: </b> " . $preg_pattern; echo "<hr>"; echo "<b>Result: </b> " . $func_preg_replace; echo "<hr>"; echo "<b>Rawurl: </b> " . rawurlencode($_GET['preg']); echo "<hr>"; echo "<b>Ord: </b> "; for ($i=0;$i<strlen($func_preg_replace);$i++) { echo $func_preg_replace[$i] . "(" . ord($func_preg_replace[$i]) . ") "; } echo "</div>"; } ?> <div class="mid"> <form method="get" action="preg_test.php"> <input type="text" id="preg_input" name="preg" <?php if (isset($_GET['preg'])) { echo " value='" . $_GET['preg'] . "'"; } ?>> <input type="submit"> </form> </div> </body> </html> And the string without What is love 0-9, Specialcharacters: !"#¤%&/()=? Does it reproduce for you guys? ---- Also tried to UTF-8 encode string via php, the preg_replace string, 2 new unicode blocks appeared with �(195) �(130). $func_preg_replace = utf8_encode ($func_preg_replace);
  11. How would that work with preg_replace()?
  12. Apparently my browser forces ¤ to be at url, even though i replace it with %C2%A4 (if this was what you meant). Rest of the stuff is encoded properly (chrome). But on edge it is encoded. (Image from Edge browser) Also tried urldecode the GET parameter.
  13. Changed to UTF-8 (not sure if it were already), issue still persists somehow. The odd part is, this works when the £ is not added in the preg pattern.
  14. So i'm not still really familiar with regex and how does it work, but i have issue with my code. I have ¤ in my text and it gets replace with unicode ? block. https://en.wikipedia.org/wiki/Specials_(Unicode_block) for me and I don't get why. Here is the code I'm using. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> #kool { width:800px; border:groove; margin:0 auto; padding:25px; } </style> </head> <body> <?php /* Test preg_replace function */ $preg_pattern = "/[^A-Za-z0-9!\"#%£&()=@\s]/"; if (isset($_GET['preg'])) { echo "<div id='kool'>"; echo "<b>Original string: </b> " . $_GET['preg']; echo "<hr>"; echo "<b>Preg pattern: </b> " . $preg_pattern; echo "<hr>"; echo "<b>Result: </b> " . preg_replace($preg_pattern,"",$_GET['preg']); echo "</div>"; } ?> <form method="get" action="preg_test.php"> <input type="text" name="preg" <?php if (isset($_GET['preg'])) { echo " value='" . $_GET['preg'] . "'"; } ?>> <input type="submit"> </form> </body> </html> And here is the string I'm trying to use. Test 0-9, Specialcharacters: !"#¤%&/()=? Result image below Any guides / help appreciated.
×
×
  • Create New...