AllSeoHelp.com
Search the Entire Site
  • PHP
  • JavaScript
  • CSS
  • HTML
Learn VBA & Macros in 1 Week!

PHP - $_get Always Returns Blank

Full Excel VBA Course - Beginner to Expert

$_get Always Returns Blank

View Content
When you do a search at (right sidebar):
http://ourneighborhooddirectory.org
the $_GET result is always blank. The site is hosted at Bluehost and this is a Wordpress site. You can see the result of the query because I write them out. Here is the form code:
Code: [Select]
<form method="get" action="http://ourneighborhooddirectory.org/search-results/" >
Search the Directory:
<input type="text" name="srch"/>
<input type="submit" value="Search" />
</form>
Here is the PHP code on the action page:
<?php
$srchVal = $_GET["srch"];
echo $_GET['srch'];
echo "------------ ". $srchVal." ------------";
print_r($_GET);
echo $_SERVER['QUERY_STRING'];
?>

Any ideas on why $_POST and $_GET always return blank?

Thanks for the help...


Full Excel VBA Course - Beginner to Expert

Similar Tutorials

$_get Returns Empty Always
Php Array-search Returns A Blank
Differences Between Isset($_get['']) And !$_get['']
Only Returns End Value Of $row
If Else Delima Returns Nothing In The Else
Mysql_query(); Returns Nothing
Query Returns Nothing
Select Only Returns 1 Row
If('00' == '0000') Returns True
Php Returns Undefined Variable
Php Mail() Returns False !?
Php Exec Output Returns 1 What Does This Mean
File_exists() Returns False
While Loop Returns Null
Selecting A Name From Table 2 But Get No Returns
Unserialize Returns False...
Multiple Returns From A Fetch
If Array Returns 0 Error Message?
Mail() Returns False But Email Is Sent
Can't Get This Query To Execute. Always Returns False.



Learn VBA & Macros for Excel in 1 Week!



$_get Returns Empty Always

Similar Tutorials View Content
Hi All,

I am pretty new to PHP ( I am  a C Programmer).

I am trying a simple shopping cart website for my friend.

IN one of the pages, I am submitting some info, which is actually not showing up in my server side php.
Below is the HTML code to submit.

<a href="cart.php?action=add&p=5&size=small"> <img src="images/add_to_cart.gif"/> </a>

I tried to check the values of the parameters using

$action  = $_GET['action'] ;

Action stored empty. Then I checked the whole array

print_r($_GET) which returned 

Array( )

So, for some reason the value is always empty.
I tried the declaration GLOBAL $_GET, but no use. 

Any help/directions - much appreciated!


Php Array-search Returns A Blank

Similar Tutorials View Content

In the following code: echo $text[2] returns the word at that index but echo $key returns a blank.

Can someone explain why is array-search not working in this  indexed array?

It does work when I test it with a key => value type array.

<?php $myfile = fopen("test.txt", "r") or die("Unable to open file!");

while(!feof($myfile)) {

  $text[] = fgets($myfile); }

fclose($myfile);

$word = $_POST['word'];

$key = array_search($word, $text);

echo $key ?>


Differences Between Isset($_get['']) And !$_get['']

Similar Tutorials View Content
A few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET['']

I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET['']

I do use isset(), though.


Only Returns End Value Of $row

Similar Tutorials View Content

Hello, i have a query that returns the rows of certain parts of a databse.

i made a button on the end of each echo, to make sure that, the button being printed with each echo, correlates to that echo. However, the SESSIONS only return the same varaibles each time. The last in the list.

$sql = "SELECT p.Title, p.PerfDate, p.PerfTime FROM performance AS p INNER JOIN production AS r ON p.Title = r.Title";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
       echo '<tr>
<td>'.$row['Title'].'</td>
<td>'.$row['PerfDate'].'</td>
<td>'.$row['PerfTime'].'</td>
<td><button name="availability" value="'.$row['Title'].'">Availability</button></td> 
</tr>';

$_SESSION["Title"] = $row['Title'];
$_SESSION["PerfDate"] = $row['PerfDate'];
$_SESSION["PerfTime"] = $row['PerfTime'];



    }
} else {
    echo "0 results";
}

$_SESSION["name"] = $_GET["name"];

?>

How am i able to make it so each button correlates to each row?

 

There's a screenshot of how it looks for reference 

Edited December 8, 2019 by AdamSteele

If Else Delima Returns Nothing In The Else

Similar Tutorials View Content
I'm getting frusted over an if else statememt that won't work.  It is calling one variable from the table.  If the variable is in the table it will display one thing, if the variable is absent, it should display something else.  I've tried !empty, isset, even $num_rows =1, but the content in the else doesn't display.  Here's the code:

Code: [Select]

<?
$result = mysql_query( "SELECT * FROM codeWords WHERE Mycode = '$MyCode' " )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
  while ($row = mysql_fetch_array($result))
  {
     extract($row);
     
if (!empty( $MyCode  )) {   
echo "here is the code word";
} else {
echo "you need to go back and get the code";
}
$row_count++;
}
mysql_close;
?>

When the code variable is correct the "here is the code word" displays.  when the code variable is incorrect, what should appear as "you need to go back and get the code" is just blank.

Any thoughts on how to structure the query in such a way that eh incorrect text appears?

Thanks,




Mysql_query(); Returns Nothing

Similar Tutorials View Content
I'm hoping someone can help me cos my hair's going white with this one. I'm trying to put together a script that acts as web-based interface to an SQL server. There are actually two parts, admin.htm and admin.php. The first part is just a form that passes login credentials to the PHP file. That part seems to work fine, but I'll post the source anyway: -

Code: [Select]
<!DOCTYPE HTML>

<html lang="en">

<head>

<title>SQL admin login</title>

<meta charset="iso-8859-1" />

</head>

<body>

<form action="admin.php" method="post">
<label for="username">Username: -</label>
<br />
<input type="text" name="username" id="username" />
<br />
<br />
<label for="password">Password: -</label>
<br />
<input type="password" name="password" id="password" />
<br />
<br />
<label for="server">Server: -</label>
<br />
<input type="text" name="server" id="server" />
<br />
<br />
<label for="database">Database: -</label>
<br />
<input type="text" name="database" id="database" />
<br />
<br />
<input type="submit" value="Login" />
<input type="reset" value="Reset" />
</form>

</body>

</html>

Following is the content of admin.php. By this point I can see the connection in MySQL Workbench, and when I submit the query 'SELECT * FROM subscribers' it's being stored in '$_POST['query']', but 'mysql_query($_POST['query'],$_SESSION['con']);' is returning nothing. There is definitely a record in that table, and the user I'm logging on with has permission to run the 'SELECT' command against this database, so I can't figure out why mysql_query(); is returning nothing: -

Code: [Select]
<!DOCTYPE HTML>

<?php

session_start();

if(!$_SESSION['con'])
{
   if(!($_POST['username'] || $_POST['password']))
   {
      if(!($_SESSION['username'] || $_SESSION['password']))
      {
      $error="Username and password variables empty.";
      }
   }
   else
   {
      $_SESSION['username']=mysql_real_escape_string($_POST['username']);
      $_SESSION['password']=mysql_real_escape_string($_POST['password']);
      $_SESSION['server']=mysql_real_escape_string($_POST['server']);
      $_SESSION['database']=mysql_real_escape_string($_POST['database']);
      $_SESSION['con']=mysql_pconnect($_SESSION['server'],$_SESSION['username'],$_SESSION['password']);
      if(!$_SESSION['con'])
      {
         $error="Failed to connect to server.";
      }
      else
      {
         $database=mysql_select_db($_SESSION['database'],$_SESSION['con']);
         if(!$database)
         {
            $error="Failed to connect to database.";
         }
      }
   }
}

if(!$_POST['query'])
{
   $error="No query submitted.";
}
else
{
   $result=mysql_query($_POST['query'],$_SESSION['con']);
   if(!$result)
   {
      $error="Query returned nothing.";
   }
}

?>

<html lang="en">

<head>

<title>SQL admin interface</title>

<meta charset="iso-8859-1" />

</head>

<body>

<form action="admin.php" method="post">
<textarea name="query" rows="10" cols="50">SELECT * FROM subscribers</textarea>
<br />
<br />
<input type="submit" value="Submit query" />
</form>

<?php

if($error)
{
   echo $_POST['query']."<br /><br />".$result."<br /><br />".$error;
   die();
}
else
{
   while($row=mysql_fetch_assoc($result))
      {
         echo $row['name']." ".$row['email'];
         echo "<br />";
      }
}

?>

</body>

</html>

Can anyone help?

MOD EDIT: [code] . . . [/code] tags added.


Query Returns Nothing

Similar Tutorials View Content
this is supposed to display the distinct first two characters of a string(billnmbr) in a combobox
ive tried this on phpmyadmin and it returns 08..
which is correct
when i run this on my server, it returns nothing..
there must be something wrong with the way i called the billnmbr
does anybody have an idea on how i could call and display this correctly?
thanks and have a nice day.

<?php
  $mquery = "select distinct(substring(`billnmbr`, 1, 2)) from `tbltest`";
  $mres =mysql_query($mquery) or die(mysql_error());
   while($mrow=mysql_fetch_array($mres)){
$mm = $mrow['billnmbr'];
 echo "<option value=" . $mrow['billnmbr'] . ">";
 echo $mrow['billnmbr'] . "</option>"; 
} 
 echo " </select>";
  ?>



Select Only Returns 1 Row

Similar Tutorials View Content
im not new enough for this to take so long to figure out, but for some reason
$rs = mysql_query("SELECT * FROM cl");

returns the last record instead of all the records in the table. anyone know why it wouldnt take everything?


If('00' == '0000') Returns True

Similar Tutorials View Content

<?php
if('00' == '000')
echo 'weired';
?>


Please consider the code above. Strangely it echoes the word "weired".

Also if('00' == '000000000000000') returns true and so forth.

What is really going on?

Thanks in advance

By the way the php version is 5.3.9 on wampserver 2.2



Php Returns Undefined Variable

Similar Tutorials View Content
Hi again everyone!

I'm sitting here, developing the same site - on my localhost the site is working great!

Then when I upload it, to another testserver (production for developers), I get following:

Notice: Undefined variable: db in C:\xampp\htdocs\lucas\sidebar.php on line 3

Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\lucas\inc\functions.php on line 13



I'm wondering why I get it, because if I do a try / catch on the db connection, and do a select * on the content table, it returns results, the paths should be almost the same..

On localhost I run: localhost/lucas/, on the prod-server I run liveip/lucas/

Can any spot the problem?

I'm not a big xampp dude myself,

I've attached an dump of my PHP info also, just rename the .php to .html

Thank you a lot!
Lucas R / Zerpex


Php Mail() Returns False !?

Similar Tutorials View Content

Php Exec Output Returns 1 What Does This Mean

Similar Tutorials View Content
Hi i am running a wamp server on windows 7

i am trying to php exec command to run a command but the output returns 1 does this mean the cmd failed to execute ?

Code: [Select]

$openssl_cmd = "($OPENSSL mime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE ".
"-outform der -nodetach -binary <<_EOF_\n$data\n_EOF_\n) | " .
"$OPENSSL smime"." -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE";



File_exists() Returns False

Similar Tutorials View Content
Hi,


I am trying to verify if the given url exists or not, by using file_exists() function.

It always returns 'FALSE' , according to my understanding it happening because the file to be checked on the given url is located in safe mode.

Could anyone please suggest as to how this could be overcome, by similar function or by using alternative method.

Regards
Abhishek Madhani


While Loop Returns Null

Similar Tutorials View Content

Hi, I am trying to expand my very limited PHP by building a CMS. It's all new to me so please be courteous with your replies ?

I little history of my problem.

I am running xampp on a windows 10 running php 5.6.38

I have taken two video courses and on each I got stumped halfway through with a very similar problem.
The first was using mysql which I was converting to mysqli until I run into a problem.
I then started a new course which used mysqli but it was from 2014 so not sure which version of PHP or if it would even matter.

I am copying everything word for word and even downloaded the course file on the first one and still got the same problem so I'm wondering if there is something wrong with my setup - config?.

The problem.
I am trying to pull data from the database using a while loop. Each time it returns NULL.

This is the code:
 

<?php 

error_reporting(E_ALL);
ini_set('display_errors',1);

include("includes/database.php");
include("includes/header.php");

if ($connection) {        
    echo "Great, we're connected to the database<br><br>";
    }else {
        echo "Bummer, it didn't connect to the database!";
        }

     $query = "SELECT * FROM categories";
   $result_set = mysqli_query($connection, $query) ;

   if (!$result_set) {
           die("Query Failed".msqli_error($connection));
               }

   while ($row = mysqli_fetch_array($result_set)) {
               echo $row['cat_title'];
               }

    var_dump($result_set);                      
        
 ?>


This is the response:

Great, we're connected to the database

object(mysqli_result)#3 (5) { ["current_field"]=> int(0) ["field_count"]=> int(2) ["lengths"]=> NULL ["num_rows"]=> int(0) ["type"]=> int(0) }

Question:
the database table (categories) is populated with two rows (id & cat_title) and there is data in there.
So why does it not retrieve the data?

 

Thanks for your help.


Selecting A Name From Table 2 But Get No Returns

Similar Tutorials View Content
I have a table called users with a fieldname called service_id.  In a table called services I have id and name.

I want to query the users table and, based on the service_id, display the name of the service (which is stored in the services table).

However, when I try this code I get
No records returned.

I later echo out under a while statement $row['name']; or $row['id']


$query = "SELECT users.username, users.lname, users.fname, users.service_id, services.name, services.id 
FROM users, services 
WHERE users.inst_id = '".$userarray['inst_id']."' and users.id !='".$userarray['id']."' and users.service_id = services.id ";



Unserialize Returns False...

Similar Tutorials View Content
I am trying to unserialize this string:

a:3:{s:3:\"zip\";s:5:\"55068\";s:4:\"city\";s:9:\"Rosemount\";s:5:\"state\";s:2:\"MN\";}

but I unserialize is returning false.

Why is it doing that?

$info = unserialize($_COOKIE['zipcode']);
var_dump($info);


Multiple Returns From A Fetch

Similar Tutorials View Content

Me again.. I'm fetching data from MySQL but each person in people.php is displayed two times instead one.. The issue must be inside models_category_tbl table, because each person have more then one result. Any advice is appreciated. What should I do?

I would like to display people something like that:

1 John Doe 1 IT developer, 3 mechanic

models/model = person

category = occupation/skills

MySQL:

model_index table
+---------+------------+-------------+-------------------+---------------+----------------+
|model_id | model_name | model_title | model_description | model_country | model_slug	  |
+---------+------------+-------------+-------------------+---------------+----------------+
| 1 	  | John Doe   | Johns title | Johns desc        | Hungary       | john-doe 	  |	
+---------+------------+-------------+-------------------+---------------+----------------+

models_category_tbl table
+-------------+---------------------+---------------------+
| category_id | model_category_name | model_category_slug |
+-------------+---------------------+---------------------+
| 1           | it developer        | it-developer        |
| 2           | photographer	    | photographer        |
| 3           | mechanic            | mechanic            |
+-------------+---------------------+---------------------+

models_category_ids table
+----+----------+-------------+
| id | model_id | category_id |
| 1  | 1        | 1           | 
| 1  | 1        | 3           |
+----+----------+-------------+

 

PHP function to fecth data:

        public function getAllModels1 () {

        $sql = "SELECT * FROM models_index  JOIN models_category_ids ON models_index.model_id=models_category_ids.model_id JOIN models_category_tbl ON  models_category_tbl.category_id=models_category_ids.category_id" ;
            $stmt = $this->conn->prepare($sql);
            $stmt->execute();
            $result = $stmt->fetchAll((PDO::FETCH_OBJ));
            
            return $result;            
    }

 

people.php

<?php 
declare(strict_types=1);
ob_start();
include "includes/connect.php";
include "includes/functions.php";
 

   	$model = new ModelsData();
	$models = $model->getAllModels1();


	foreach ($models as $model) { ?> 


	<a href="model.php?id=<?= $model->model_id ?>"><img src="<?= $model->model_img_path ?><?=$model->model_img_name ?>"></a>	 
 
	<?php echo $model->model_id . " " .  $model->model_name . " " . $model->category_id .  " " . $model->model_category_name  ; ?>
	

	<h3><?= $model->model_name ?></h3>

 
<?php }  ?>

 

Output:

 1 John Doe 1 IT developer 
 1 John Doe 3 mechanic

 


If Array Returns 0 Error Message?

Similar Tutorials View Content
friends if an array returns results as Array() how could i set an error message to it? i tried to do a if statement to the $variable but not working


Mail() Returns False But Email Is Sent

Similar Tutorials View Content
Hi, I'm pretty new to PHP and I am working on a form that sends and email. I want to display a message if the mail can't be sent (i.e. if mail() returns false) and a different message if mail() returns true, except it is returning false even though the emails are sending.


Basically I have used:

$to = 'myemail@email.com';
$subject = "Subject Line Goes here";
$headers = "From: $email";
$message = 'My message';

$mailSent = mail($to, $subject, $message, $headers);

In testing it I have used the following to determine what is going on:

   if (isset($mailSent)) { echo '$mailSent ='.$mailSent; } - echo's nothing
   if ($mailSent == FALSE) { echo '$mailSent = FALSE'; } - echo's '$mailSent = FALSE'
   if ($mailSent == TRUE) { echo '$mailSent = TRUE'; } - echo's nothing
   if (is_null($mailSent)) { echo '$mailSent = NULL'; } - echo's '$mailSent = NULL'
   echo '$mailSent ='.$mailSent; - echo's '$mailSent ='

Any help would be greatly appreciated!
Thanks!


Can't Get This Query To Execute. Always Returns False.

Similar Tutorials View Content
Hi all ! The following code has two similar queries. Query 1 and Query 2. While Query 1 works just fine, Query 2 simply fails persistently. I have not been able to figure out why?   I have checked every single variable and field names but found no discrepancy of any sort or any mismatch of spelling with the fields in the database.   I would be grateful if anybody can point out what is preventing the second query from returning a valid mysqli object as the first one does. Here is the code for the two.
<?php
$db_host = "localhost";
$db_user ="root";
$db_pass ="";
$db_database ="allscores";

//////////////// CHECKING VARIABLE FILEDS IN A UPDATE QUERY //////////////////////////////////
//////////////// QUERY 1 /////////////////////////////////////////////////////////////////////

/*
$db_database ="test";
$db_table ="users";
$RecNo = 1;			
		
$field1 = 'name';
$field2 = 'password';
$field3 = 'email'; 
$field4 = 'id';
$val1 = "Ajay";
$val2 = "howzatt";
$val3 = "me@mymail.com";


					$con = mysqli_connect($db_host,$db_user,$db_pass,$db_database) or die('Unable to establish a DB connection');
					$query = "UPDATE $db_table SET $field1 = ?,
							$field2 = ?, $field3 = ?
							WHERE $field4 = ? ";   // session terminated by setting the sessionstatus as 1 
					$stmt = $con->prepare($query);
					var_dump($stmt); 
					$stmt->bind_param('sssi',$val1,$val2,$val3,$RecNo);
					if($stmt->execute())
					{
						$count = $stmt->affected_rows;
						echo $count;
					}		
//////////////// QUERY 1  END /////////////////////////////////////////////////////////////////////
*/



//////////////// QUERY 2 /////////////////////////////////////////////////////////////////////

$con = mysqli_connect($db_host,$db_user,$db_pass,$db_database) or die('Unable to establish a DB connection');
$table = 'scores';
$date = date('Y-m-d H:i:s');


/*
$prestr 	= "Mrt_M_";		
$STATUS		= $prestr."Status";
$S_R1 		= $prestr."Scr_1";
$S_R2 		= $prestr."Scr_2";
$PCT 		= $prestr."PPT";
$DPM 		= $prestr."DSP";
$TIMETAKEN 	= $prestr."TimeTaken";
*/


$STATUS		= "Mrt_M_Status";
$S_R1 		= "Mrt_M_Scr_1";
$S_R2 		= "Mrt_M_Scr_2";
$PPT 		= "Mrt_M_PPT";
$DSP 		= "Mrt_M_DSP";
$TIMETAKEN 	= "Mrt_M_TimeTaken";

$TimeOfLogin	=	$date;	
$no_of_logins	=	10;
$time_of_nLogin	=	$date;
$m_scr_row1		=	5;
$m_scr_row2		=	5;
$m_ppt			=	20;
$m_dsp			=	60;
$m_time			=	120;
$date			=	$date;
$RecNo			=	24;

		$query = "UPDATE $table SET 
				TimeOfLogin = ?,
				no_of_logins = ?,
				time_of_nLogin = ?,
				$S_R1 = ?,					
				$S_R2 = ?,					
				$PPT = ?,						
				$DSP = ?,						
				$TIMETAKEN = ?,				
				$STATUS = '1',				
				TimeOfLogout = ?,
				WHERE RecNo = ?";			
		$stmt = $con->prepare($query);

		var_dump($stmt);

		$stmt->bind_param('sisiiddssi',$TimeOfLogin,$no_of_logins,$time_of_nLogin,$m_scr_row1
					$m_scr_row2,$m_ppt,$m_dsp,$m_time,$date,$RecNo);
		if($stmt->execute()) echo " DONE !";


?>	




Thanks to all
Privacy