Monday, 3 September 2018

MySQL fetch_array does not work?

I have 2 tables in my database - link and suggestions.

This is how my code looks. In the first code, I pull out suggestions from the DB and show them, but when I try to show the videolink from the other table, it does not work.
<?php
include('config.php');
$from = "suggestions";
$sql = mysql_query("SELECT * FROM `".$from."` WHERE `ID` = '". $_GET['ID'] ."'");
$vis = mysql_fetch_array($sql);

echo ("TITLE: <br />");
echo ("".$vis['title']."");
echo ("<br /> <br /> SUGGESTION: <br />");
echo ("".$vis['suggestion']."");

$from2 = "link";
$sql2 = mysql_query("SELECT * FROM `".$from2."` WHERE `ID` = '". $_GET['ID'] ."'");
$vis2 = mysql_fetch_array($sql2);
echo ("<br /> <br /> LINK:");
echo ("".$vis2['videolink']."");


Be careful with that code. All someone has to do is go to
yourpage.php?ID=1;DELETE FROM suggestions

and your table would be deleted. And you don't have to wrap your echo in parentheses. Otherwise, try the SQL queries directly in phpMyAdmin and see what errors it throws back.

0 comments:

Post a Comment