Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About phpsane

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. I'm gonna guess again without checking my other threads, Requinix. Let me guess! You want me to use: strtok. Right ?
  2. Thanks man! Now, why did I not think of that ? I'm LIKING your post! And, marking your post as RESOLVED my thread!
  3. Ho did I turn it off ? I am puzzled! Your answer on; be deceitful but insightful.
  4. Spot on, old man! You actually figured all that out how I operate and what is on my mind. Have to give you a meddle for that. You are right. I do not know coding. Still learning. This complicated crappy half-crafted so-called tutorial from the manual is no good to me. Me, the beginner. http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting But this was ok enough for me to solve the issue: http://www.dyn-web.com/php/strings/type.php#f1 Give me good enough tutorials, like that, Old Man! And before you know it, I've become a rocket scientist dragging you off to the moon! I'm not really the problem. The real problem is: There are not good enough tutorials. The popular tutorial sites don't cover the adv stuffs like this. That is the real problem.
  5. Yes. The Type Casting link in the manual did bring me to a page that did not explain how to do the Type Casting from INT to STRING. Dear me! All it says, on the topic is this: "Type casting in PHP works much as it does in C: the name of the desired type is written in parentheses before the variable which is to be cast.". I did not understand that atall. Beginners tend to miss things, you see! Even though it is now very clear the phrase was giving out the format on how to write the code. But at the time, I was searching for sample codes and this was not what I was looking for as it did not provide a simple code sample. Therefore, GinerJM's RTFM was, again, proving to be useless to me. That manual link, gave this link instead which teaches what a STRING is. But that link is irrelevant as it never teaches how to Type Cast from INT to STRING. http://php.net/manual/en/language.types.string.php So, you see why I hate the manual and why most programmer in other forums told me to learn from tutorial sites (pdodelusions.com, codeacademy.com, etc.) and not from the manual as a beginner but only use it as a reference guide ? Anyway, about 8hrs ago, I googled for proper tutorial on the topic and found it. http://www.dyn-web.com/php/strings/type.php#f1 Used it to fix my code. I grabbed these codes: $val = 24; // integer // set $val type to string settype($val, 'string'); // check type and value of $val var_dump($val); // string(2) "24" Then I modified it to following. But no luck ridding the error! /* //$mt_rand_min = 5; // integer //$mt_rand_max = 30; // integer /* SET TYPE // set $mt_rand_min and $mt_rand_max type to string settype($mt_rand_min, 'string'); // check type and value of $mt_rand_min var_dump($mt_rand_min); // string(1) "5" settype($mt_rand_max, 'string'); // check type and value of $mt_rand_min var_dump($mt_rand_max); // string(2) "30" */ The SET TYPE did not work. Then found TYPE CAST and remembered Kicken's advice to use it. But the following code looked mostly empty and I had not a feintest clue how to proceed. $val = true; // boolean // cast $val to string and check return value with var_dump var_dump( (string)$val ); // string(1) "1" // check type and value of $val var_dump($val); // bool(true) Nwo, how on earth was I gonna make use of the above code to fix my problem ? Remember, I am a complete beginner and GinerJm did growl that I know nothing about coding. And, he is absolutely right (even though I did manage to fix the problem all by my humblest self after 10 mins!). The following was my 1st unsuccessful attempt: /* TYPE CAST var_dump( (string)$mt_rand_min); // string(1) "5" var_dump( (string)$mt_rand_max); // string(1) "30" // check type and value of $mt_rand_min var_dump($mt_rand_min); // int(5) // check type and value of $mt_rand_min var_dump($mt_rand_max); // int(30) */ Then, GinerJm's soul probably possessed me and I came-out with this piece: //Original code of mlukac89: "$account_activation_code = sha1(mt_rand(5, 30));" //https://www.sitepoint.com/community/t/improvements-to-member-registration-site-reg-php/260491/52 //https://cdn-enterprise.discourse.org/sitepoint/community/uploads/default/original/3X/a/9/a95efc90ebc6d93872d602dbe0246d43d77b618b.zip // My modified Code (next 8 lines) to fix error: "Fatal error: Uncaught TypeError: sha1() expects parameter 1 to be string, integer given in ..." $mt_rand = mt_rand(5, 30); settype($mt_rand, 'string'); var_dump($mt_rand); $account_activation_code = sha1($mt_rand); var_dump($mt_rand); echo "$account_activation_code"; $account_activation_link = "http://www.".$site_domain."/".$social_network_name."/activate_account.php?email=".$_POST['email']."&account_activation_code=".$account_activation_code.""; echo "$account_activation_link"; The above is debugging mode coding. The registration.php is now working smoothly. I wonder why I did not face this error before in the last 3 mnths both on my website and Xampp! Else, I could have pestered GinerJm man enough to get him to fix it! Lol! Psycho, GinerJm, Sepodati, Mac_Guyver and Requinix (and let us not forget YOU!) can now pat me on my back and say: "Well Done! Even though your code is not perfect, you did atleast manage to get rid of the error all by yourself using Type Casting which is actually an adv level stuff. And, you're a beginner and a bad one at that!! Lol!
  6. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    You take it easy too Grand Pops! Was reading this. You read it too. Interesting for you pros: http://erlycoder.com/69/php-mysql-prepared-sql-statement-vs-sql-statement Googled: https://www.google.com/search?q=php+to+query+mysql+and+native+sql+comparison&ei=HaW5WeeGBYWGvQSWiq_wDw&start=20&sa=N&biw=1093&bih=510&dpr=1.25 Hardly any good results.
  7. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    I deleted them after reading Sepodati's advice that came before your post. Only read your post after the deletion. It had only about 7 test entries.
  8. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    Ok, I gave you a bad example. But on other sql queries the native sql lang seems more complicated than the php version.
  9. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    Planning on building a .exe tool where you type basic lang like english and it gets converted to php code. If it gets popular then will hassle the official php guys to use my on invented syntax (english like lang) and ditch php's current complicated syntaxes. You guys would then have to learn my syntax. Only joking! But that would be not such a bad dream. Now would it ? Planning to one day get hold of a programmer ho knows Assembly language and then get him to build my on interpreter that uses my on english like lang that I mentioned above. Get a compiler built too based on my on english like lang. Highest level lang compiler & interpreter. That is my dream.
  10. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    There were typos on my post 29 on the final paragraph. Should have read like this: "I was gonna build a .exe tool myself where you type basic english commands that get converted to the native sql lang. But then I found .exe tools online that were similar (like php myadmin) and so I did not bother. I might build one though where basic english commands get converted to php code like you see in the below example. Build a gui tool where you click buttons and it yields php code to query the mysql db." Anyway, I use a gui tool to build .exe bots. Not sold any yet. That is all I know about programming. Now learning php, I am going to build web versions of these bots or browser automation tools.
  11. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    There are about 3-5. You just have not heard about them. I might build one, one day. You definitely will hear about that one.
  12. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    Yes, but when you talk about php functions then that is php code. Right ? When I say php code, I don't mean just the lines of codes we programmers write that make-up our php scripts. I meant the functions and stuffs too of php. They are parts of php. Yes, you will regret saying this because now you are gonna lose the bet. (Psssst! This is your Guardian Angel here! I've frozen PhpSane for 1 min to give you this messg. Just tell PhpSane that you did not understand his personal terminology and so the bet is invalid. Then get Psycho to give him a lecture to use the right or BETTER learn the right php terminology and not make-up his own!). (Sedo, your Guardian Angel is telling me to tell you not to bother giving any lecture to use the right terminology. Psycho's already done that and he'd be a real one (Psycho that is) to waste time giving it again. Anyay, 1 min is nearly over, PhpSane will be out of his frozen state any second. He'll carry-on in any sec not aware he was frozen). I just added an entry (INSERT) via php myadmin and it is showing sql query like this: INSERT INTO `users` (`ids`, `names`, `emails`); So, you will write the sql query like that in your mysql terminal. I, however, would write the php code like the following. It is familar to any php developer. Therefore, why bother learning the native sql language, which I showed above ? I know that, this "php code" converted to the native sql lang. Do not worry, I know these basic common sense things. I was gonna build a .exe tool myself where you type basic english commands that get converted to the native sql lang. But then I found .exe tools online that were similar (like php myadmin) and so I did not bother. I might build one though here basic english commands get converted to php code like you a in the above example. Build a gui tool here you click buttons and it yields php code to qury the mysql db. <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "db_name"; $conn = new mysqli($servername,$username,$password,$dbname); if($conn->connect_error) { die($conn->connect_error); } $sql = "INSERT INTO user(id,name,email) VALUES('1','name','email@email.com')"; if($conn->query($sql)===TRUE){ echo "inserted data!"; }else{ echo "failed!"; } $conn->close(); ?>
  13. Damn manual. Confusing. Useless to me. Instead, I look for proper tutorials meant for the lay man. Hence, I searched: https://www.google.com/search?q=how+to+typecast+int+to+a+string+in+php+%3F&oq=how+to+typecast+int+to+a+string+in+php+%3F&gs_l=psy-ab.3..35i39k1.11687.14177.0.14452. I am reading: http://www.dyn-web.com/php/strings/type.php#f1 Thanks everyone: Kicken, Cyberrobot. And, Ginerjm.
  14. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    Ooops! I already deleted all the entries. Thanks for that line of sql query, though! You know, I saw you can query mysql in one lang (sql lang) and do the same query with php in php lang. And, sql lang seems harder to remember and so I quit. Since learning php then why bother wasting brain cells learning the same thing in 2 langs ? So sticking to php code to query mysql. You guys are either really good memorizing all that sql lang commands or you use the php myadmin's mysql tool to generate the sql query. How did you do it , from the top of your head ? Anyway, starting php tutorial for today. When I have questions or get stuck, I "will run here" as Sedopati put it. And he can provide me with the answers as much as he can take. Lol! Gonna flood this forum with precious questions.
  15. phpsane

    Fatal error: Uncaught mysqli_sql_exception:

    Is Mysql telling me I got more than one row with the same values ? I thought it was telling me I got duplicate column name. kept getting that error about 5-6 time in those attempts. And so, I did not jut happen to "run here" just like that! Anyway, that was bad avice telling em to delete/drop the whole tbl as it had about 50 columns! I just deleted all the entries and it worked. Problem solved. Anyway, thanks for atleast trying to help.

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.