intodesi Posted May 24, 2008 Share Posted May 24, 2008 OK, does anyone see any problems with the following, and where I have the blue text below, what syntax would I use to achieve that statement? <?php $type = $_GET['type']; if ($_GET['proof']) { $project = mysql_real_escape_string($_GET['proof']); } elseif ($_GET['invoice']) { $project = mysql_real_escape_string($_GET['invoice']); } else { [color=blue]"If neither of the above are present i want this to do nothing"[/color] } $image = "SELECT '$type' FROM pages WHERE project_id='$project' LIMIT 1"; $result2 = mysql_query($image); header("Content-type: image/jpeg"); echo mysql_result($result_2, 0); ?> Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/ Share on other sites More sharing options...
jonsjava Posted May 24, 2008 Share Posted May 24, 2008 leave out the else. If neither is true, then it will do nothing. Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549032 Share on other sites More sharing options...
intodesi Posted May 24, 2008 Author Share Posted May 24, 2008 Scratch this should have been $result2 Getting an Error Warning: Wrong parameter count for mysql_result() in /home/techurch/public_html/zinto/clients/clients/clients.php on line 60 Line 60 is echo mysql_result($result_2); Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549039 Share on other sites More sharing options...
intodesi Posted May 24, 2008 Author Share Posted May 24, 2008 Still Getting an error line 60 code Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/techurch/public_html/zinto/clients/clients/clients.php on line 60 Code <?php $type = $_GET['type']; if ($_GET['proof']) { $project = mysql_real_escape_string($_GET['proof']); } elseif ($_GET['invoice']) { $project = mysql_real_escape_string($_GET['invoice']); } $image = "SELECT '$type' FROM pages WHERE project_id='$project' LIMIT 1"; $result2 = mysql_query($image); echo mysql_result($result2, 0); <--Line 60 here ?> and if it helps echo ("<td><a href='index.php?c=clients&proof=$row[project_id]&type=proof'>Proof Available Click Here</a></td>"); index.php?c=clients&proof=1&type=proof all fields are getting passed properly Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549042 Share on other sites More sharing options...
BlueSkyIS Posted May 24, 2008 Share Posted May 24, 2008 $result2 = mysql_query($image) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549044 Share on other sites More sharing options...
intodesi Posted May 24, 2008 Author Share Posted May 24, 2008 OK ive decided not to store the images in a database, so I am just using the database to store the file name. I am using this code $type = $_GET['type']; $id = $_GET['id']; $sql = "SELECT '$type' FROM projects WHERE project_id='$id' LIMIT 1"; $result = mysql_query($sql); $image = mysql_result($result); echo ("<img src='/$type/$image/' />"); echo $image; echo $type; ?> but that doesn't seem to be working, i am using the echo $image and echo $type to see if the variables are being passed and they are except the echo $image is displaying the variable from $type, not sure whats going on.. also, i have it set so that $type is also the folder so that img src="$type works, so i dont think the rpoblem is there Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549234 Share on other sites More sharing options...
minidak03 Posted May 24, 2008 Share Posted May 24, 2008 This might not work sorry I didn't test this but I think i see an issue with your SQL statement. $image = "SELECT '$type' FROM pages WHERE project_id='$project' LIMIT 1"; Should be $image = "SELECT $type FROM pages WHERE project_id='$project' LIMIT 1"; No need for the single quotes around $type after SELECT because it will be searching for the wrong name unless your name also incldues the single quotes around it. Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549246 Share on other sites More sharing options...
intodesi Posted May 24, 2008 Author Share Posted May 24, 2008 ah, i see, i should have know better hehe.. well i got this to work also $type = $_GET['type']; $id = $_GET['id']; $sql2 = "SELECT * FROM projects WHERE project_id='$id' LIMIT 1"; $result2 = mysql_query($sql2); $image = mysql_fetch_assoc($result2); echo ("" .$type ." for ".$image[project].""); echo ("<br />"); echo ("<img src='clients/clients/$type/$image[$type]' />"); ?> replacing $type with just an *, but I am going to plug what you suggested in also, because thats the route i would like to take Link to comment https://forums.phpfreaks.com/topic/107094-solved-ifs-elfifs-and-else-statement-help/#findComment-549248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.