Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:58:50+00:00 2026-06-06T02:58:50+00:00

How do I check that the php script works? I’m using php -f filename.php

  • 0

How do I check that the php script works? I’m using php -f filename.php email@address.com, but I get errors. The php script is intended to work with an Android app to retrieve data where the email matches a posted email address. Here is the php code:

<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("db_name", $con);
$email= mysql_real_escape_string($_POST['email']);
$result=mysql_query("SELECT * FROM `TableName` WHERE email='$email' ");

if($result){ 
  $num_rows = mysql_num_rows($result);
  print(json_encode($num_rows));
}

  mysql_close($con);
?> 

Or am I not able to test this script from the command line, and instead should use an html file?

Now, for example if I replace the line: $email= "myaddress@nd.edu"; and then type php -f getdbstats.php I get the correct result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:58:51+00:00Added an answer on June 6, 2026 at 2:58 am

    Command line php is a little different. It does not use POST or GET global arrays to store command line parameters. You have to use global variable called $argv which is populated with parameters from the command line. So in you code, email address is stored in the $argv[1] element of the array. $argv[0] is the name of the script.
    Read more here:
    http://php.net/manual/en/reserved.variables.argv.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that check if the referrer has been cleared after
I'm trying to make a PHP script that will check the HTTP status of
I made a little PHP script that checks if an email is valid. The
I have a URL that would be like so: http://mysite.com/index.php?somename=somevalue I usually check that
Possible Duplicate: Check that an email address is valid on iOS What is the
I've got a PHP script in the works that is a job worker; its
I'm posting data from a Flex app to a php script. GET works fine
I have a php script that shows all the picasa public albums by using
I'm looking a symbol regex in PHP that will check submitted usernames and reject
I have a PHP code, that will run a Select query to check if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.