Jump to content
MakeWebGames

Car Images - Re Visited


m1ll1k3n

Recommended Posts

so the other day i posted a way i found of making car images work, and urbanmafia kindly shared his simple way of adding car images to garage 

since this , ive also added it so that when a user steals the car that also calls the image to be pulled up via the db

however the current issue im having is , im tryint ti make it possible to re-view the car ,by reading the cars id , then finding the pic field in the db from this for some reason this isnt working and i was wondering if anyone could points out what im doing wrong here ?

 


 public function method_view() {
            
            $id = $this->methodData->id;
            
            $car = $this->db->prepare("SELECT * FROM garage INNER JOIN cars ON (CA_id = GA_car) WHERE GA_id = :car");
            $car->bindParam(':car', $id);
            $car->execute();
            $car = $car->fetchObject();
            
            if (empty($car) || $car->GA_uid != $this->user->id) {
                
                $this->alerts[] = $this->page->buildElement('error', array("text"=>'You dont own this car or it does not exist!'));
            
            } else {
              
                
                
                $this->alerts[] = $this->page->buildElement('success', array(
                        "text" => '<img src="http://criminalempire.co.uk/<{image}>"><br>Your Currently Viewing '));                    
                
               $this->db->query("UPDATE userStats SET US_money = US_money + 0 WHERE US_id = ".$this->user->id);
     
                $actionHook = new hook("userAction");
                $action = array(
                    "user" => $this->user->id, 
                    "module" => "garage.view", 
                    "id" => $car->CA_id, 
                    "success" => true, 
                    
                );
                $actionHook->run($action);
            
            }
            
        }

 

its now successfuly reading the car id .. and i can now click on the car and view the car id .. the problem im having is with 

 

  $this->alerts[] = $this->page->buildElement('success', array(
                        "text" => '<img src="http://criminalempire.co.uk/{image}"><br>Your Currently Viewing '));          

 

this for some reason not alowing me to call the image even though its showing the car id , and then reading the CA_image table .. but for some reason this isnt working and i dont know why 

image.thumb.png.e43185dc406bca387ec945b26030d934.png

this is what i get ... but am yet to actualy get any sort of picture 

please if somone could help that would be great 

 

Link to comment
Share on other sites

$this->alerts[] = $this->page->buildElement('success', array(
                        "text" => '<img src="http://criminalempire.co.uk/' . $id.  '<br>Your Currently Viewing '));   

Edited by Sim
Link to comment
Share on other sites

image.thumb.png.2b860a29e8fe4f8ab5839fef4784bb92.pngthats what you get with that ? 

id will just show the image ... im not having a problem calling the id as it was already taking me to http://criminalempire.co.uk/?page=garage&action=view&id=349

 

its just this "text" => '<img src="http://criminalempire.co.uk/{image}"><br>Your Currently Viewing '));   

for some reason {image} or <{image}> wont call the /cars/car.jpg like it does on theft.inc.php?

 

 

 } else {
                    $success = true;
                    $this->alerts[] = $this->page->buildElement('success', array(
                        "text" => '<img src="http://criminalempire.co.uk/'.$image.'"/><br>You successfuly stole a '.$carName.' with '.$carDamage.'% damage.'
                    ));

 

that works 100% fine on theft

 

 

which is why i though "text" => '<img src="http://criminalempire.co.uk/<{image}>"/><br>Your Currently Viewing '));  would work as <{image}> works on the table just bellow in garage

Edited by m1ll1k3n
Link to comment
Share on other sites

<img src="http://criminalempire.co.uk/<{image}>"><br>Your Currently Viewing ')); 

What is {image} supposed to be. You do know you have < > these around {image} I would think that would throw the image path off. What is the image path of image if your right click on image

Link to comment
Share on other sites

"text" => '<img src="http://criminalempire.co.uk/{image}" width="600" height="400"/><br>Your Currently Viewing '));  

tahts what im running atm but its still not working 

i get : http://criminalempire.co.uk/ as a image adress when running that 

 

and when i try and use 

  "text" => '<img src="http://criminalempire.co.uk/<{image}>" width="600" height="400"/><br>Your Currently Viewing ')); 

i get : http://criminalempire.co.uk/<>  as an image adress , i run it with <> purly because the same thing worked on theft and on the picture on the garages table bellow , but now neither seem to work on the garages page regardlesss weather its {image} or <{image}>

im just trying to get it to call the image from table 

image.thumb.png.837b08af89c804a6d7b6bfd8433039b8.png

this is where it takes me when i click on view car 

http://criminalempire.co.uk/?page=garage&action=view&id=361

so thats working fine ,but still wont call the image aswell as the id for some reason ... or do i need it to call image from the id in the table?

Link to comment
Share on other sites

this should work for you, one thing you need to remember when on PHP files use the PHP variable and not the HTML template variable also you didnt define the image so you would need to select the column that contains the data.

public function method_view() {
            
            $id = $this->methodData->id;
            
            $car = $this->db->prepare("SELECT * FROM garage INNER JOIN cars ON (CA_id = GA_car) WHERE GA_id = :car");
            $car->bindParam(':car', $id);
            $car->execute();
            $car = $car->fetchObject();
            
            if (empty($car) || $car->GA_uid != $this->user->id) {
                
                $this->alerts[] = $this->page->buildElement('error', array("text"=>'You dont own this car or it does not exist!'));
            
            } else {
             
                $this->alerts[] = $this->page->buildElement('success', array(
                        "text" => '<img src="'.$car->CA_pic.'"><br>Your Currently Viewing '));                    
            }
		}

This should work for you also removed those extra SQL's from the end as they could interfere with users. 

Edited by urbanmafia
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...