PHP/MySQL 2 Bilder in einer Variable

  • Hallo, ich habe ein kleines problem :/
    Undzwar arbeite ich grade an einem Firmenpanel.
    und habe folgendes Problem:


    Das scheint nicht richtig zu funktionieren.
    Das eine bild hat den CarName = Huntley
    und das 2. CarName = Roadtrain
    nunja. ich will das bild in der tabelle mit $img ausgeben damit es dynamisch bleibt aber ich bekomme es nicht hin :(
    ich habe auch eine Tabelle für die Bilder. aber derzeit benutze ich sie nicht

  • Der Operator = setzt einen Wert.
    Mit == können Sie einen Vergleich durchführen, mit === können Sie den Datentyp vergleichen.
    Also ändern Sie Ihre = in den IF Abfragen zu == und es sollte funktionieren.


    mit freundlichem Gruß
    Timo Schneider


    -----


  • Darf ich dir einen Optimierungs Tipp geben:

    PHP
    <?php
       $img='<img src="Assets/Images/'.$TakeCarResult["CarName"].'.png" alt="'.$TakeCarResult["CarName"].'">';
    ?>


    So müsstest du nur jedes Bild so nennen wie das Fahrzeug, und das richtige Bild wird automatisch eingefügt.

  • @CristianW
    Ich habe jetzt ein noch größeres problem... bei aufräumen meines webservers (Login datein ACC panel usw verschoben) habe ich meine Login.php geschrottet. sie kann entweder nicht mehr überprüfen Ob die Login details stimmen oder sie schaft die weiterleitung nicht. ich probiere das jetzt wirklich schon seit 2 stunden. aber ohne erfolg.


    PHP
    <?php require_once('../Connections/SatDB.php'); ?><?php //require_once('SatDB.php');?><?php/*if (!isset($_SESSION)) {  session_start();}*/$MM_authorizedUsers = "0";$MM_donotCheckaccess = "true";// *** Restrict Access To Page: Grant or deny access to this pagefunction isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {   // For security, start by assuming the visitor is NOT authorized.   $isValid = False;   // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.   // Therefore, we know that a user is NOT logged in if that Session variable is blank.   if (!empty($UserName)) {     // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.     // Parse the strings into arrays.     $arrUsers = Explode(",", $strUsers);     $arrGroups = Explode(",", $strGroups);     if (in_array($UserName, $arrUsers)) {       $isValid = true;     }     // Or, you may restrict access to only certain users based on their username.     if (in_array($UserGroup, $arrGroups)) {       $isValid = true;     }     if (($strUsers == "") && false) {       $isValid = true;     }   }   return $isValid; }/*$MM_restrictGoTo = "Login.php";if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {     $MM_qsChar = "?";  $MM_referrer = $_SERVER['PHP_SELF'];  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)   $MM_referrer .= "?" . $QUERY_STRING;  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);  //header("Location: ". $MM_restrictGoTo);   exit;}*/if (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  if (PHP_VERSION < 6) {    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  }  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {    case "text":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;        case "long":    case "int":      $theValue = ($theValue != "") ? intval($theValue) : "NULL";      break;    case "double":      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";      break;    case "date":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;    case "defined":      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;      break;  }  return $theValue;}}$query_Login = "SELECT * FROM `User`";$Login = mysql_query($query_Login, $SatDB) or die(mysql_error());$row_Login = mysql_fetch_assoc($Login);$totalRows_Login = mysql_num_rows($Login);?><?php// *** Validate request to login to this site./*if (!isset($_SESSION)) {  session_start();}*/$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) {  $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['UserName'])) {  $loginUsername=$_POST['UserName'];  $password=$_POST['Password'];  $MM_fldUserAuthorization = "UserLevel";  $MM_redirectLoginSuccess = "../Account/Account.php";  $MM_redirectLoginFailed = "../Account/Login.php";  $MM_redirecttoReferrer = true;  mysql_select_db($database_SatDB);  $LoginRS__query=sprintf("SELECT Username, Password, UserLevel FROM `User` WHERE Username = %s AND Password = %s",  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));   //$LoginRS = mysql_query($LoginRS__query) or die(mysql_error());  $LoginRS = mysql_query($LoginRS__query, $SatDB) or die(mysql_error());  $loginFoundUser = mysql_num_rows($LoginRS);  if ($loginFoundUser) {    $loginStrGroup  = mysql_result($LoginRS,0,'UserLevel');    //declare two session variables and assign them    $_SESSION['MM_Username'] = $loginUsername;    $_SESSION['MM_UserGroup'] = $loginStrGroup;	          if (isset($_SESSION['PrevUrl']) && true) {      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	    }    header("Location: " . $MM_redirectLoginSuccess );  }  else {    header("Location: ". $MM_redirectLoginFailed );  }}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link href="../CSS/Layout.css" rel="stylesheet" type="text/css" /><link href="../CSS/Menu.css" rel="stylesheet" type="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>San Andreas Trucking | Login</title><script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script><link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /></head><body><p>&nbsp;</p><div id="Holder"><div id="Header"></div><div id="NavBar">	<nav class="navbar navbar-inverse">  		<div class="container-fluid">    		<div>      			<ul class="nav navbar-nav">        			<li class="dropdown">                      <a class="dropdown-toggle" data-toggle="dropdown" href="#">Login                      <span class="caret"></span></a>						<ul class="dropdown-menu">           				 		<li><a href="../Account/ForgotPassword.php">Passwort vergessen</a></li>          		</ul>       			 </li>        		<li><a href="../Account/Register.php">Registrieren</a></li>       </ul>    </div>  </div></nav></div><div id="Content">	<div id="PageHeading">	  <h1>&nbsp;</h1>	  <h1>Login	</h1>	</div>	<div id="ContentLeft">	  <h2>Support:</h2>      <h6>&nbsp;</h6>      <h6>Email: bedrockcracher@gmail.com</h6>      <h6>&nbsp;</h6>      <h6>codet by Yannik Böltes alias	Derek Westbrook</h6>	</div>    <div id="ContentRight">      <form id="LoginForm" name="LoginForm" method="POST" action="<?php echo $loginFormAction; ?>">        <table width="400" border="0" align="center">          <tr>            <td><h6>Benutzername:</h6>              <h6><span id="sprytextfield1">                <label>                  <input name="UserName" type="text" class="StyleTextField" id="UserName" />                </label>            <span class="textfieldRequiredMsg">Es muss ein Wert angegeben werden.</span></span></h6></td>          </tr>          <tr>            <td>&nbsp;</td>          </tr>          <tr>            <td><h6><span id="sprytextfield2">              <label>Passwort:<br />                <br />                <input name="Password" type="text" class="StyleTextField" id="Password" />              </label>            <span class="textfieldRequiredMsg">Es muss ein Wert angegeben werden.</span></span></h6></td>          </tr>          <tr>            <td>&nbsp;</td>          </tr>          <tr>            <td><label>              <input type="submit" name="Einloggen" id="LoginButton" value="Einloggen" />            </label></td>          </tr>          <tr>            <td>&nbsp;</td>          </tr>        </table>      </form>    </div></div><div id="Footer">  </br>  <h6><a href="../Impressum.php">Impressum</a></h6></div></div><script type="text/javascript"><!--var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");//--></script></body></html><?phpmysql_free_result($Login);?>


    Vielleicht wisst ihr ja des rätsels lösung