Forum Moderators: phranque
And the form you fill in :
<snip>
My web guys are having trouble replicating it and diagnosing it. Can anyone help?
[edited by: physics at 4:34 pm (utc) on Feb. 21, 2006]
[edit reason] No URL drops please. [webmasterworld.com...] [/edit]
Here's the error I'm getting:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Only one top level element is allowed in an XML document. Error processing resource 'http://www.example.com/usethiscarto...
<b>Warning</b>: Missing argument 2 for checkname() in <b>/home/.magpie/example/example.com/validate...
And here's the code for the page:
<?
require('config.inc');
include('form.inc');
require('validate.inc');
$errs = array();
if ( $submit ) {
$tmp = checkname($name);
if (strlen($tmp)){ array_push($errs, $tmp); }
$tmp = checkphone($telephone);
if (strlen($tmp)){ array_push($errs, $tmp); }
$tmp = checkemail($email);
if (strlen($tmp)){ array_push($errs, $tmp); }
$tmp = checkmessage($message);
if (strlen($tmp)){ array_push($errs, $tmp); }
}
$result=mysql_query("SELECT * FROM toon WHERE id='$id'");
$row=mysql_fetch_array($result);
$thumbnail = sprintf("%04d", $row['id']).'t.jpg';
include('inc_header.php');
if ( count($errs) < 1 && $submit ) {
$stripphone=ereg_replace("[^0-9]","",$telephone);
$stripname=stripslashes($name);
$stripmessage=stripslashes($message);
$result=mysql_query("SELECT * FROM toon WHERE id=$id and lower(status) = 'active'");
$row=mysql_fetch_array($result);
$msg="Use This Cartoon\n\n";
$msg.="Cartoon Number: ".$row[id]."\n\n";
$msg.="Name: $stripname\n";
$msg.="Telephone: $stripphone\n";
$msg.="E-mail: $email\n";
$msg.="Referrer: $referer\n";
$msg.="Usage: $usage\n";
$msg.="Message: $stripmessage\n";
$msg.="
Server Information
----------------------------------------------------------------------
";
foreach ($_SERVER as $key => $value) {
$msg .= "$key: $value\n";
}
$mailheaders="From: $stripname <$email>\n";
$mailheaders.="Reply-To: $stripname <$email>\n\n";
mail("mark@example.com","example - Use This Cartoon",$msg,$mailheaders);
mail("nicholas@example.com","example - Use This Cartoon",$msg,$mailheaders);
?>
<p>
<img src="/images/process_illustration.gif" width="90" height="120" alt="" class="right" />
<p class="center">
Thanks for your request! I’ll get back to you right away!
<br/><br/>
<a href="/">Click here</a> to return to the main page.
</p>
</p>
<?
$result2=mysql_query("select tt.topicid from toon t, toon_topic tt ".
"where t.id = $id and lower(t.status) = 'active' and t.id = tt.toonid group by tt.topicid");
$ids = array();
while ($row2 = mysql_fetch_array($result2)) {
array_push($ids, $row2[0]);
}
$query = "select t.id, t.row from toon t, toon_topic tt ".
"where t.id!= $id and lower(t.status) = 'active' and t.id = tt.toonid ".
"and tt.topicid in (".implode(",", $ids).") ".
"group by t.id, t.row order by t.row desc";
//echo $query;
$result2 = mysql_query($query);
if (mysql_num_rows($result2)>=2){
echo"<p>If you like this cartoon, you may also like these:</p>";
$counter=0;
while ($row2=mysql_fetch_array($result2)) {
if ($row2[id]!=$id) {
if ($counter<3) {
$thumbnail=sprintf("%04d", $row2[id]).'t.jpg';
echo '<a href="toon.php?id='.$row2[id].'"><img src="/cartoons/'.$thumbnail.'" /></a> ';
$counter=($counter+1);
}
}
}
}
?>
<?
} else {
?>
<p>
I offer my cartoons for usage in your projects for very reasonable fees! Just fill in the
form below and click Submit and I’ll get back to you with a quote the same day!
(Please note - I cannot offer cartoons for unpaid usage.)
</p>
<form action="/usethiscartoon.php" method="post">
<input type="hidden" name="id" value="<? echo $id;?>" />
<div class="form">
<img src="/cartoons/<?echo $thumbnail;?>" alt="" class="right" />
<ul class="left">
<? if (count($errs) > 0) { echo '<li class="error">'.implode('<br/>', $errs).'<br/><br/></li>'; }?>
<li><label>Name</label><input type="text" name="name" size="35" maxlength="40" value="<? echo $name;?>" class="left" /></li>
<li><label>Telephone</label><input type="text" name="telephone" maxlength="14" value="<? echo $telephone;?>" size="35" class="left" /></li>
<li><label>E-mail</label><input type="text" name="email" value="<? echo $email;?>" size="35" maxlength="60" class="left" /></li>
<li><label>Referrer</label>
<select name="referer">
<?
$result = mysql_query("select id, name from referer order by id");
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row[1] . '"'.($referer == $row[1]? ' selected' : '').'>' . $row[1] . '</option>';
}
?>
</select>
</li>
<li><label>Usage</label>
<select name="usage" class="left">
<option value="Magazine">Magazine</option>
<option value="Newspaper">Newspaper</option>
<option value="Book">Book</option>
<option value="Presentation">Presentation</option>
<option value="Newsletter">Newsletter</option>
<option value="Advertising">Advertising</option>
<option value="Web site">Web site</option>
<option value="Merchandise">Merchandise</option>
<option value="Other">Other</option>
</select>
</li>
<li><label>Message</label><textarea name="message" cols="30" rows="5" maxlength="255" class="left"><? echo $message;?></textarea></li>
<li> </li>
<li><label> </label><input type="submit" name="submit" value="Click here to submit!" class="left" /></li>
</ul>
</div>
</form>
<?
}
include('inc_footer.php');
?>
Any ideas?
function checkname($str, $identifier)
{
$err = "";
$identifier = $identifier? $identifier : "name";
if ($str == ""){
$err = "Please supply a $identifier.";
} else if ( strlen($str) > 40 ) {
$err = "The $identifier must be less than 40 characters long.";
} else if (!preg_match("/^[a-z A-Z]+$/", $str)) {
$err = "The $identifier you entered contains illegal characters.";
}
return $err;
}
And the XML is baffling me too... Any ideas?
just call it like this:
checkname($name, "name");
On the XML question, it sounds like your server is telling browsers that .php page type is xml - check your server configuration