englishcodemonkey Posted September 22, 2008 Share Posted September 22, 2008 So i am lost after reading a lot about variables i want to know whether there is a way to assign a value to my variable from a mysql query. my code is : ?php require_once('conn.php'); $pic = $_REQUEST['image']; $q = "SELECT image FROM hosta, images WHERE hosta_name = $pic, imgid = hosta_id"; $r = @mysqli_query ($dbc, $q); if ($r) { while($row=mysql_fetch_array($result)){ echo "'image'$img=$row['image']"; } } $path = "http://********.com/$img"; $imagepath=$path; $image=imagecreatefromjpeg($imagepath); header('Content-Type: image/jpeg'); imagejpeg($image); ?> The variable $pic is coming from a form, but the variable $img i am hoping will be filled from my query to the database? I have only ever used queries to fill dropdown boxes or tables, so I am totally lost on how to make this a dynamic variable so to say. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/125349-using-mysql-results-as-php-variables/ Share on other sites More sharing options...
Maq Posted September 23, 2008 Share Posted September 23, 2008 echo "'image'$img=$row['image']"; First of all, this should be broken up into two lines. Like this: $img = $row['image']; echo "image: " . $img; Quote Link to comment https://forums.phpfreaks.com/topic/125349-using-mysql-results-as-php-variables/#findComment-649113 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.