m1ll1k3n Posted May 10, 2020 Posted May 10, 2020 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 this is what i get ... but am yet to actualy get any sort of picture please if somone could help that would be great Quote
Sim Posted May 10, 2020 Posted May 10, 2020 (edited) $this->alerts[] = $this->page->buildElement('success', array( "text" => '<img src="http://criminalempire.co.uk/' . $id. '<br>Your Currently Viewing ')); Edited May 10, 2020 by Sim Quote
m1ll1k3n Posted May 10, 2020 Author Posted May 10, 2020 (edited) thats 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 May 10, 2020 by m1ll1k3n Quote
Sim Posted May 10, 2020 Posted May 10, 2020 <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 Quote
m1ll1k3n Posted May 10, 2020 Author Posted May 10, 2020 "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 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? Quote
URBANZ Posted May 10, 2020 Posted May 10, 2020 (edited) 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 May 10, 2020 by urbanmafia 1 Quote
Sim Posted May 10, 2020 Posted May 10, 2020 ^^ that was my next suggestion. I overlooked the query Quote
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.