1

I am have two php scripts, say "first.php" which calls another php, "second.php" script with a GET value.

The first.php calls the second.php by using GET method.

The GET method value is a string retrieved from the database .

first.php code

$someString = mysqli_query($connectionName,"SELECT someString from db where id=1";

/* Then the php redirects to ->" */

'mywebsite.com/PHP/second.php?data='.someString

second.php

if(isset($_GET['data']))
{
     $new_data = $_GET['data'];

}

My problem is that, the data in "someString" is in resultset format ,So I am getting a php error that the GET method needs a String value.

Is there any possible way to convert the sql resultset to string?

1
  • are you using <form action="mywebsite.com/PHP/second.php"> to redirect? Commented Dec 1, 2015 at 6:46

2 Answers 2

1

Try this.

$someStringRes = mysqli_query($connectionName,"SELECT someString from db where id=1";

$row=mysqli_fetch_row($someStringRes);

$someString = $row[0];

/* Then the php redirects to ->" */

'mywebsite.com/PHP/second.php?data='.someString
Sign up to request clarification or add additional context in comments.

Comments

0

if php redirects means it will be simple

<?php
$res = mysqli_query($connectionName,"SELECT someString from db where id=1";
$row = mysql_fetch_row($res);
$data=$row[0];
header('Location: mywebsite.com/PHP/second.php?data='.$data);
?>

OR
I assumed that you used form action to transfer datas: try this

<?php
$res = mysqli_query($connectionName,"SELECT someString from db where id=1";
$row = mysql_fetch_row($res);
$data=$row[0];
?>
<form action='mywebsite.com/PHP/second.php'>
<input type="text" name="data" value="<?php echo $data;?>">
<input type="submit">
</form>

Now the url pass like this mywebsite.com/PHP/second.php?data=//value. you can retrieve it

<?php
$data=$_GET[data];
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.