Forums

This topic is locked

show blank thumbnail

Posted 22 Jul 2003 23:35:52
1
has voted
22 Jul 2003 23:35:52 Carsten Wochnik posted:
<font face='Arial'>
Hi, i've programmed a form to insert the following into my mySQL database: thumbnail, date, news.&lt;br&gt;
To upload the thumb i use the pure php upload and for the resize i use the smart image processor.&lt;br&gt;
But how can i insert an specfic thumb if no picture is choosen for the upload. Iwant to show one special picture if this happens.&lt;br&gt;
What must the if/else clause like to be?&lt;br&gt;&lt;br&gt;
here is the code:
&lt;code&gt;
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "insert") {
$insertSQL = sprintf("INSERT INTO News (news, datum, bild) VALUES (%s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['news'], "text",
GetSQLValueString($HTTP_POST_VARS['datum'], "text",
GetSQLValueString($HTTP_POST_VARS['bild'], "text");

mysql_select_db($database_testGerberhof, $testGerberhof);
$Result1 = mysql_query($insertSQL, $testGerberhof) or die(mysql_error());

$insertGoTo = "admin_start_main.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
&lt;/code&gt;&lt;br&gt;&lt;br&gt;Greetings, Carsten.
</font id='Arial'>

Replies

Replied 23 Jul 2003 13:46:28
23 Jul 2003 13:46:28 Patrick Woldberg replied:
How about adding the next code just before the insert:

<pre id=code><font face=courier size=2 id=code>&lt;?php
if ($HTTP_POST_VARS['bild'] == "" {
$HTTP_POST_VARS['bild'] = "default.jpg";
}
?&gt;</font id=code></pre id=code>

Also you could try the following;

Change:

<pre id=code><font face=courier size=2 id=code>$insertSQL = sprintf("INSERT INTO News (news, datum, bild) VALUES (%s, %s, %s)",</font id=code></pre id=code>

in:

<pre id=code><font face=courier size=2 id=code>$insertSQL = sprintf("INSERT INTO News (news, datum, bild) VALUES (%s, %s, IFNULL(%s, 'default.jpg'))",</font id=code></pre id=code>


--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
-------------------------------------------------- <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code>

Reply to this topic