0
Guys, I’m trying not to use $_GET[] on the link, but I can’t find any way to make it happen. I mean, instead of "site.com/? post=name news" stay "site.com/name-news". I’ve already reviewed forums and Stack also looking for a solution, but I can’t find anything without it disappears "? post=" from the URL. The current code is this:
<?php
if(!@mysql_connect("localhost","root",""))
{
die('ERRO NA CONEXÃO! --> '.mysql_error());
}
if(!mysql_select_db("site_novo"))
{
die('NOME DB ERRADO--> '.mysql_error());
}
$video = $_GET['video'] ;
$videoId = $video;
$video_select = "SELECT * FROM video WHERE `id_video`='$video_select'";
$query = @mysql_query($video_select) or die (mysql_error());
if (mysql_num_rows($query) <= 0) {
echo 'ESSE VÍDEO NÃO EXISTE AINDA';
}else{
$vd = mysql_fetch_assoc($query);
include_once "../assets/include/head_video.php";
}?>
RESOLUTION
<?php
if(!@mysql_connect("localhost","root",""))
{
die('ERRO NA CONEXÃO! --> '.mysql_error());
}
if(!mysql_select_db("site_novo"))
{
die('NOME DB ERRADO--> '.mysql_error());
}
$video = $_SERVER['PATH_INFO'];
$muda_path = explode('/', $video );
foreach( $muda_path as $video_link )
{
$videoID = $video_link;
$video_select = "SELECT * FROM video WHERE `id_video`='$videoID'";
$query = @mysql_query($video_select) or die (mysql_error());
}?>
What is the code of
head_video.php
?– MagicHat
What you need is to implement the friendly URL system. URL Friendly concept and a more complete example. Full example
– Marcos Souza
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title><? php echo $Vd['titulo_video']; ? > - Player </title> <link rel="stylesheet" media="screen" href=".. /Assets/css/external_embed.css? v=2.25.5" /> </head>
– Thomas Franklin
Follow this link of Stack en-us that has been fixed. http://stackoverflow.com/questions/11722711/url-routing-regex-php
– Mauro Alexandre
I actually said wrong, instead of the code you put in, which code, the
link
, that lead you to start these includes ?– MagicHat
Without using parameters, you can use $_SERVER["REQUEST_URI"] and $_SERVER["PATH_INFO"] variables depending on the context. This returns the path of the request. The only care is to have any path met by the same PHP, to process the information. Alternatively, if you use this syntax, you don’t even have to do anything complex: example.com/news.php/eneadactilo-e-preso-tentando-sair-do-pais , then all you need is one of the variables mentioned.
– Bacco
@Magichat is what I intend to use on multiple pages, and getting add the same head on each page does not help if you need to add or take out some css. That’s just the "embed page".
– Thomas Franklin
@Bacco, is there an example I can rely on?
– Thomas Franklin
the example is you save a file like news.php just with this line:
<?php echo $_SERVER['PATH_INFO'];
and access it as a.com/news.php/newsnumber-twelve address, to see how the variable behaves. Once you understand how it is filled in, then you make the logic for your select.– Bacco
@Bacco I am exploring the
$_SERVER['PATH_INFO'];
here, I created a php called "test" and changed$video = $_GET['video'] ;
for$video = $_SERVER['PATH_INFO'];
, but it’s returning "/" together, I’ll try to blow up the "/" to get only the ID.– Thomas Franklin
@Bacco, @Magichat, went like this
<?php 
if(!@mysql_connect("localhost","root",""))
{
 die('oops connection problem ! --> '.mysql_error());
}
if(!mysql_select_db("site_novo"))
{
 die('oops database selection problem ! --> '.mysql_error());
}
$video = $_SERVER['PATH_INFO'];
$palavras = explode('/', $video );
foreach( $palavras as $video_link )
{
 $videoId = $video_link;
 $leitura = "SELECT * FROM video WHERE
id_video='$videoId'";
 $query = @mysql_query($leitura) or die (mysql_error());
}
?>
thanks a lot guys!!– Thomas Franklin
https://answall.com/a/77846/28632
– AlfredBaudisch