Jump to content

lenny

Members
  • Posts

    2
  • Joined

  • Last visited

lenny's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. lenny

    Switch Question

    Thanks man. I have set up a mysql database but I have some trouble with what code I should use.I got this working but I'm not sure if it's the right way to do it: <?php$input = $_GET['img'];$con = mysql_connect('stuff','stuff','stuff');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db('stuff', $con);$result = mysql_query("SELECT img_name,width,height FROM images WHERE img_id='$input'");$output = mysql_fetch_array($result);echo '<img src="images/' . $output['img_name'] . '" width="' . $output['width'] . '" height="' . $output['height'] . '" alt="" />';mysql_close($con);?> Also, I want it to write 'Image not found' if the '?img=' is wrong or something, but I don't know how. Any suggestions?And is there any security things I should know or do? Can the '?img=something' contain underscores , dots etc. ?Thanks again for any help...
  2. lenny

    Switch Question

    Hello all...I'm making a gallery with images and I have this show image page, with php using the switch statement so all thumbs is linking to it using ?img=something. It works allright and like it's supposed to, but how well does a switch work with many cases(like 100, 200 or more) ?Would a database(or similar) work better, faster and more effective, than a switch with alot of cases in the php file?Also, I'm new to php.I hope you understand what I mean...Thanks...
×
×
  • Create New...