Jump to content

[SOLVED] if's elfif's and else statement help


intodesi

Recommended Posts

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);
?>

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);

 

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

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

 

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.