Jump to content

SheenLim08

Members
  • Content Count

    15
  • Joined

  • Last visited

Everything posted by SheenLim08

  1. I'm a novice about anything web apps so I just follow the book and research what it does as I go. the book I am following is "Learning PHP, MySQL Javascript 5th edition" in the latest version of its series i believe.
  2. I corrected the wrong part but it still the same.
  3. I did that at the end of the <script> tag
  4. Hi Guys, I am following this book to learn php. Supposedly it will get return html contents from another site using async methods via XMLHttpRequest. Now here is my main page calling the async method. When I try to setup breakpoints in php on the urlpost.php the line "if (filter_has_var(INPUT_POST, 'url')) {" returns false. What am i doing on the main page causing the javascript variable "params" not being posted on the PHP/Web Server?
  5. Or whats the alternative way of debugging javascript?
  6. I have been very hesitant in learning web development because it has no many moving parts, but a month ago I started learning using the book "Learning PHP, MySQL & Javascript" by Robin Nixon on O'Reilly and I have been very happy with it. My current object is the following. 1. Read and Learn "Learning PHP, MySQL & Javascript" by Robin Nixon 2. Read and Learn "Pro PHP MVC" by Pitt, Chris 3. Create a POS/Inventory System to test out learned knowledge. You may see me post in this forum from time to time and seek help, as I learn you stuff I hope I can give back to the community and help others if I can. But for now, study first. God Speed to Everyone!
  7. Hi PHP Freaks, In my last post, you have known that I was studying PHP, i have reached the part of the book im reading for Javascript and I am very happy with all the things I have learned so far. However, I do need help in my remote debugging for java scripts. Setup: Laptop - Where netbeans is installed. Ubuntu Webserver - is where the project is located, this is running on a VirtualBox VM. Project: The project is deployed n the Ubuntu Webserver and everytime i run debug or start the project from Ubuntu Webserver a directory sync will start from my laptop to the ubuntu webserver. I was able to successfully configured PHP remote debugging with Netbeans and now I need it for javascript. I was redirected to a Chrome plugin named "Netbeans Connector", I have already configured my Netbeans project to use Chromium with Netbeans Connector (See attached), but when i ran the project, i get a "Browser refused to debug this tab". I actually prefer if all my development tools will be on one IDE environment rather than jumping around with other tools to achieve the same thing. Can anyone help me configuring my Netbeans do remote debugging for a project located on my Ubuntu Webserver? Any help is appreciated.
  8. I got it resolved!!!! Thanks for all of your help and more power to this community. Here is what i did (Kicken and requinix was very helpful). added phpinfo() in one of my php pages. as in (Like Kicken recommends) <?php phpinfo(); include_once "./login.php"; spl_autoload_register(function ($className) { $file = __DIR__ . '\\' . $className . ".php"; $file = str_replace('\\', DIRECTORY_SEPARATOR, $file); if (file_exists($file)) { include_once $file; } }); I noticed that the php.ini file loaded in the apache server is different from the php.ini file on the php interactive, which was the one i was configuring. APACHE: Loaded Configuration File /etc/php/7.2/apache2/php.ini PHP Interactive: Loaded Configuration File => /etc/php/7.2/cli/php.ini I updated the "/etc/php/7.2/apache2/php.ini" with the following values. [xDebug] zend_extension = /usr/lib/php/20170718/xdebug.so xdebug.remote_autostart=on xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=192.168.56.1 xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.remote_mode=req xdebug.idekey="netbeans-xdebug" Restarted Apache server. My Guess is, /etc/php/7.2/cli/php.ini is what the PHP Builtin web server uses, this makes sense because projects that uses php built-in web server are usually where both PHP and Netbeans are installed on the same host. I learned something new today, thank you again guys.!!
  9. Hi kicken, I think you are correct, i ran the phpinfo() inline to the php files and ran it on apache. There is on xdebug.remote* entries on the page. How do i correct this? * Sorry for this noob question.
  10. Below is the phpinfo() from the ubuntu server. xdebug xdebug support => enabled Version => 2.7.2 IDE Key => netbeans-xdebug Support Xdebug on Patreon: https://www.patreon.com/bePatron?u=7864328 Supported protocols DBGp - Common DeBuGger Protocol Directive => Local Value => Master Value xdebug.auto_trace => Off => Off xdebug.cli_color => 0 => 0 xdebug.collect_assignments => Off => Off xdebug.collect_includes => On => On xdebug.collect_params => 0 => 0 xdebug.collect_return => Off => Off xdebug.collect_vars => Off => Off xdebug.coverage_enable => On => On xdebug.default_enable => On => On xdebug.dump.COOKIE => no value => no value xdebug.dump.ENV => no value => no value xdebug.dump.FILES => no value => no value xdebug.dump.GET => no value => no value xdebug.dump.POST => no value => no value xdebug.dump.REQUEST => no value => no value xdebug.dump.SERVER => no value => no value xdebug.dump.SESSION => no value => no value xdebug.dump_globals => On => On xdebug.dump_once => On => On xdebug.dump_undefined => Off => Off xdebug.extended_info => On => On xdebug.file_link_format => no value => no value xdebug.filename_format => no value => no value xdebug.force_display_errors => Off => Off xdebug.force_error_reporting => 0 => 0 xdebug.gc_stats_enable => Off => Off xdebug.gc_stats_output_dir => /tmp => /tmp xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p xdebug.halt_level => 0 => 0 xdebug.idekey => netbeans-xdebug => netbeans-xdebug xdebug.max_nesting_level => 256 => 256 xdebug.max_stack_frames => -1 => -1 xdebug.overload_var_dump => 2 => 2 xdebug.profiler_aggregate => Off => Off xdebug.profiler_append => Off => Off xdebug.profiler_enable => Off => Off xdebug.profiler_enable_trigger => Off => Off xdebug.profiler_enable_trigger_value => no value => no value xdebug.profiler_output_dir => /tmp => /tmp xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p xdebug.remote_addr_header => no value => no value xdebug.remote_autostart => On => On xdebug.remote_connect_back => On => On xdebug.remote_cookie_expire_time => 3600 => 3600 xdebug.remote_enable => On => On xdebug.remote_handler => dbgp => dbgp xdebug.remote_host => 192.168.56.1 => 192.168.56.1 xdebug.remote_log => no value => no value xdebug.remote_mode => req => req xdebug.remote_port => 9000 => 9000 xdebug.remote_timeout => 200 => 200 xdebug.scream => Off => Off xdebug.show_error_trace => Off => Off xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.show_mem_delta => Off => Off xdebug.trace_enable_trigger => Off => Off xdebug.trace_enable_trigger_value => no value => no value xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.trace_output_dir => /tmp => /tmp xdebug.trace_output_name => trace.%c => trace.%c xdebug.var_display_max_children => 128 => 128 xdebug.var_display_max_data => 512 => 512 xdebug.var_display_max_depth => 3 => 3
  11. Hi requinix, Sorry for the confusion, both laptop and VM does connect to the 192.168.56.1 9000 with the same output. I attached screenshot of both result. I also attached the netbeans screenshot when it does run the debug but is stuck on "Waiting For Connection". even though port 9000 is opened.
  12. telnet failed from laptop to laptop..hmmm..this is the result when I telnet to my laptop, and it stays that way until i close the terminal tab. I am doing this when the netbeans debugger is running (when the port 9000 is opened). sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ telnet 192.168.56.1 9000 Trying 192.168.56.1... Connected to 192.168.56.1. Escape character is '^]'. I am not sure how to answer the 2nd question. URL to the apache2 virtual host is www.phptutorial.com, the ip resolves to 192.168.56.101. I edited the laptop's hostfile /etc/hosts so that www.phptutorial.com points to the Ubuntu Server VM ip address to 192.168.56.101. So when I visit/ran the project via webserver, i just type in http://www.phptutorial.com from my laptop. Any recommendations about telnet connection to 9000?
  13. Hi requinix, you are right. telnet connection from my UbuntuServer VM to my laptop:9000 is not successful. The laptop and ubuntu server's ufw service is stopped. I did notice that tcp6 (i guess its ipv6) is listening to :9000 but not the tcp (ipv4): sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ netstat -tulpn (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - tcp6 0 0 ::1:45915 :::* LISTEN 15956/java tcp6 0 0 :::9000 :::* LISTEN 15956/java tcp6 0 0 ::1:631 :::* LISTEN - udp 0 0 127.0.0.53:53 0.0.0.0:* - udp 0 0 0.0.0.0:68 0.0.0.0:* - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp 0 0 0.0.0.0:42398 0.0.0.0:* - udp 0 0 0.0.0.0:55077 0.0.0.0:* - udp6 0 0 :::58094 :::* 2834/Preload.js --b udp6 0 0 :::46110 :::* - udp6 0 0 :::5353 :::* - But when running ss, it does show it is listening to all ports/IP for 9000 or am I reading that wrong. sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ ss -tulpn Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port udp UNCONN 0 0 127.0.0.53%lo:53 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:68 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:631 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:5353 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:55077 0.0.0.0:* udp UNCONN 0 0 *:58094 *:* users:(("skypeforlinux",pid=2834,fd=55)) udp UNCONN 0 0 [::]:46110 [::]:* udp UNCONN 0 0 [::]:5353 [::]:* tcp LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:* tcp LISTEN 0 5 127.0.0.1:631 0.0.0.0:* tcp LISTEN 0 50 [::1]:45915 [::]:* users:(("java",pid=15956,fd=20)) tcp LISTEN 0 50 *:9000 *:* users:(("java",pid=15956,fd=271)) tcp LISTEN 0 5 [::1]:631 [::]:* sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ Any idea how to configure netbeans to also listen to ipv4 for xdebug?
  14. Hi Guys, I am learning PHP via Netbeans IDE in LinuxMint because it just feels closer to Visual Studio which I used in the past, i am trying to lean more with open source technologies. I spin up a VirtualBox and installed apache2 on ubuntu. I created the netbeans project from my linuxMint to the virtualbox apache2 server (remote server) and configured the virtual directories on the apache2 server. I can the test project successfully, however I cannot seem to debug via Netbeans like toggling a breakpoint to view variable values. I found on the internet i need to configure xdebug and followed this site and used this page https://xdebug.org/wizard.php to create and install my xdebug. I then updated my php.ini file to the following: [xDebug] zend_extension = /usr/lib/php/20170718/xdebug.so xdebug.remote_autostart=on xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=192.168.56.1 xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.remote_mode=req xdebug.idekey="netbeans-xdebug" While my netbeans session id is configured "netbeans-xdebug" and debugger port to 9000. However, when i set a breakpoint in my code, netbeans seems to be stuck on "Waiting for connection" even it already passed the breakpoint. I suspect it's not even connected at all. I do see from my host laptop (where I am running netbeans) that port 9000 does open when running the project with debug and ufw is turned off in both virtualbox machine and laptop. Any ideas?
  15. Thanks Barand, adding the attributes worked for me. I also searched the PDO->setattribute on https://www.php.net/manual/en/pdo.setattribute.php on the PHP manual to have a better understanding about the attribute values. Thanks for your help.
  16. Hi PHP enthusiast, I hope you are having a wonderful day, I am learning PHP as a hobby and learning the ways of PHP talking to SQL. I have the following PHP code. login.php $mysqlDSN = "mysql:host=127.0.0.1;dbname=mysql_tutorial;port=3306;charset=utf8"; $mySQLUsername = "phpuser"; $mySQLUserPass = "Welcome123!"; phpsearchresult.php if (filter_has_var(INPUT_POST, 'txtISBN')) { try { require_once './login.php'; $sqlConnection = new PDO($mysqlDSN, $mySQLUsername, $mySQLUserPass); $sqlConnection-> $sqlStatement = $sqlConnection->prepare("SELECT * FROM classics WHERE isbn = :isbnSearchID"); $parameters = [ ":isbnSearchID" => sanitiseForSQL($sqlConnection, filter_input(INPUT_POST, 'txtISBN')) ]; if ($sqlStatement->execute($parameters)) { $result = $sqlStatement->fetch(PDO::FETCH_ASSOC); if ($result) { printf("<br />"); printf("ISBN: " . sanitiseForHTML($result['isbn']) . "<br />"); printf("Author: " . sanitiseForHTML($result['author']) . "<br />"); printf("Book: " . sanitiseForHTML($result['title']) . "<br />"); printf("Category: " . sanitiseForHTML($result['category']) . "<br />"); printf("Year: " . sanitiseForHTML($result['year']) . "<br />"); printf("Type: " . sanitiseForHTML($result['type']) . "<br />"); } else { printf("<p>The ISBN you are looking for has not been found!</p>"); printf("<a href=\"phpsearchbook.php\">Go back to Search page.</a>"); } } else { printf("<p>There was an issue during the search query!</p>"); printf("<a href=\"phpsearchbook.php\">Go back to Search page.</a>"); } } catch (PDOException $ex){ printf("<p>" . $ex->getMessage() . "</p>"); } catch (Exception $ex) { printf("<p>" . $ex->getMessage() . "</p>"); } finally { $result = null; $sqlStatement = null; $sqlConnection = null; } } function sanitiseForSQL(PDO $sqlConnection, string $variable) : string { $returnValue = stripslashes($variable); return $sqlConnection->quote($returnValue); } function sanitiseForHTML($variable) : string { $returnValue = htmlentities($variable); return $returnValue; } } The line that is saying "if ($result) {" is returning false when I'm expecting it to return true. Once a is redirected (via form post) to phpsearchresult.php, the variable txtISBN has a value of 9780099535974. However if I manually query enter the following in a mySQL cli. SELECT * FROM classics WHERE isbn = '9780099535974' I am getting good results, is there any wrong with how I add the value for the named placeholder?
×
×
  • 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.