1

I am trying to do a mysql fetch using a variable in my sql query.. Unfortunately I have no idea why the query is not working.

After the $_GET I have the echo to make sure that that was actually working, which it is, but the error seems to be occurring where the actually query is going

<?php
$con=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$scout_id = $_GET['scout_id'];
echo "scout_id: ".$scout_id;

/*This is where the error is */
$result = mysqli_query($con,"SELECT * FROM scouts WHERE scout_id='$scout_id' ");
$row = mysql_fetch_row($result);

var_dump($row);
?>

If anyone would be able to help I would be most appreciative!

1
  • Your query is subject to SQL injections and is a security hazard. Never use user input (GET, POST, COOKIE) directly in a query. Commented Apr 3, 2015 at 4:05

1 Answer 1

2

You are mixing mysqli with mysql

Change

$row = mysql_fetch_row($result);

To

$row = mysqli_fetch_row($result);
Sign up to request clarification or add additional context in comments.

1 Comment

Oh my goodness you are a genius! Thank you so much! I completely overlooked that part.

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.