Modification code php pour passage en php 7.4
Posté : ven. 17 mars 2023 15:15
Bonjour, suite à un changement de serveur mon code php ne fonctionne plus , je suis passé en PHP 7.4
comment modifier mon code?
merci d'avance
voici le code
extract(shortcode_atts(array('iddomaine' => '0'), $atts));
// on se connecte à MySQL
$db = mysql_connect('localhost', 'bmdcformacom', '971admin971');
// on sélectionne la base
mysql_select_db('testbmdcformacom',$db);
$sql = "SELECT post_title,post_name,meta_value
FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_postmeta.meta_key = '_thumbnail_id'
AND wp_posts.post_name ='".$iddomaine. "'
ORDER BY post_title";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$idimage="";
$nomdomaine="";
while($data = mysql_fetch_assoc($req))
{
$nomdomaine = $data['post_title'];
$idimage = $data['meta_value'];
}
$sql = "SELECT guid
FROM wp_posts
WHERE wp_posts.ID =".$idimage."";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$monimage ;
while($data = mysql_fetch_assoc($req))
{
$monimage = $data['guid'];
}
echo '<a href="https://institutformacom.com/audit-cons ... ne.'"><img class="featureimage" src="'.$monimage.'"></img>
<div class="titre_domaine">'.utf8_encode($nomdomaine).'</div></a>
' ;
echo('<style>
.titre_domaine{
text-align:center;
line-height:25px;
margin-top:30px;
}
.featureimage{
display: block;
margin-left: auto;
margin-right: auto
}
</style>
');
mysql_close($db);
comment modifier mon code?
merci d'avance
voici le code
extract(shortcode_atts(array('iddomaine' => '0'), $atts));
// on se connecte à MySQL
$db = mysql_connect('localhost', 'bmdcformacom', '971admin971');
// on sélectionne la base
mysql_select_db('testbmdcformacom',$db);
$sql = "SELECT post_title,post_name,meta_value
FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_postmeta.meta_key = '_thumbnail_id'
AND wp_posts.post_name ='".$iddomaine. "'
ORDER BY post_title";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$idimage="";
$nomdomaine="";
while($data = mysql_fetch_assoc($req))
{
$nomdomaine = $data['post_title'];
$idimage = $data['meta_value'];
}
$sql = "SELECT guid
FROM wp_posts
WHERE wp_posts.ID =".$idimage."";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$monimage ;
while($data = mysql_fetch_assoc($req))
{
$monimage = $data['guid'];
}
echo '<a href="https://institutformacom.com/audit-cons ... ne.'"><img class="featureimage" src="'.$monimage.'"></img>
<div class="titre_domaine">'.utf8_encode($nomdomaine).'</div></a>
' ;
echo('<style>
.titre_domaine{
text-align:center;
line-height:25px;
margin-top:30px;
}
.featureimage{
display: block;
margin-left: auto;
margin-right: auto
}
</style>
');
mysql_close($db);