My sql connection does not work
I found this partial script on another forum and thought this would be useful for aff link management. I've tried adding this:
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
correct but for some reason it won't connect. Am I mission something?
Here is all of it:
|
hi i have a database like this id | sitename | url 1 ABC abc.com 2 XYZ xyz.com 3 PPP ppp.com i wanted to create a redirect script like www.mysite.com/goto.php?url=(id number) and that id number would lead to related url respectively. for example if i try www.mysite.com/goto.php?url=2 then xyz.com will open and if i try www.mysite.com/goto.php?url=1 then abc.com will open |
<?php
$id = $_GET['id'];
//validate id
if(!is_numeric($id)) :
?>
Invalid url id
<?php
else :
$query = "SELECT url FROM tableName WHERE id = '$id';";
$res = @mysql_query($query);
if(!$res) :
?>
An error has occured
<?php
else :
if($row = @mysql_fetch_array($res)) :
header('Location: ' . $row[0]);
else :
?>
URL could not be found
<?php
endif;
endif;
endif;
?>
--= -Spazzle- =--
Learn AI Powered Content Creation
at Prompt and Prosper
Facebook, Youtube like/dislike/ safe views , Twitter, Instagram
Google Plus, Pinterest, Instagram, Vimeo, Vine