Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with if (mb_strlen() != #)
    primarykey
    data
    text
    <p>This is probably really dirty and messy code, so any input on that would be helpful as well, but my main issue is that I can't get the "ISBN" input to process if the string is the correct number of characters (10 or 13). I'm not sure where it is going wrong. It's on line 64.</p> <p>Please help! Thank you.</p> <p> </p> <pre><code>&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Link Generator&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php function showForm() { if (empty($_POST['title'])) { $title = "Book Title"; } else { $title = $_POST['title']; } ?&gt; &lt;form action="&lt;?php $_SERVER['PHP_SELF'] ?&gt;" method="post"&gt; Search by ISBN&lt;br /&gt; &lt;input type="text" maxlength="13" name="ISBN" size="30" value="ISBN" onblur="if(this.value == '') { this.value='ISBN'}" onfocus="if (this.value == 'ISBN') {this.value=''}" /&gt;&lt;br /&gt; &lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt; Search by Title &lt;strong&gt;and&lt;/strong&gt; Author&lt;br /&gt; &lt;input type="text" maxlength="13" name="title" size="30" value="&lt;?php echo $title; ?&gt;" onblur="if(this.value == '') { this.value='Book Title'}" onfocus="if (this.value == 'Book Title') {this.value=''}" /&gt;&lt;br /&gt; &lt;input type="text" maxlength="13" name="aname" size="30" value="Author Name" onblur="if(this.value == '') { this.value='Author Name'}" onfocus="if (this.value == 'Author Name') {this.value=''}" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;input type="submit" name="submit" value="Generate Link" /&gt; &lt;/form&gt; &lt;?php } function generateLink_ISBN() { echo "Your link has been generated:&lt;br /&gt;"; echo "http://xxx.com/uhtbin/cgisirsi.exe/x/0/0/5?search_type=search&amp;searchdata1=" . $_POST['ISBN'] . "&amp;library=ALL&amp;sort_by=PBYR"; } function generateLink_title() { echo "Your link has been generated:&lt;br /&gt;"; echo "http://xxx.com/uhtbin/cgisirsi.exe/x/0/0/5?search_type=search&amp;searchdata1=" . $_POST['title'] . "+" . $_POST['aname'] . "&amp;library=ALL&amp;sort_by=PBYR"; } if(isset($_POST['submit'])) { if (isset($_POST['ISBN']) &amp;&amp; isset($_POST['title']) &amp;&amp; isset($_POST['aname']) &amp;&amp; ($_POST['ISBN'] == 'ISBN') &amp;&amp; ($_POST['aname'] == 'Author Name') &amp;&amp; ($_POST['title'] == 'Book Title')) { echo "&lt;h1&gt;You did not input any information&lt;/h1&gt;"; showForm(); } elseif (isset($_POST['ISBN']) &amp;&amp; ($_POST['ISBN'] != 'ISBN')) { if (isset($_POST['ISBN']) &amp;&amp; ($_POST['ISBN'] != 'ISBN') &amp;&amp; (!is_numeric ($_POST['ISBN']))) { echo "&lt;h1&gt;The ISBN you entered did not contain all numerics&lt;/h1&gt;"; showForm(); } elseif (isset($_POST['ISBN']) &amp;&amp; ($_POST['ISBN'] != 'ISBN') &amp;&amp; ((mb_strlen($_POST['ISBN'], 'utf-8') != 13) | (mb_strlen($_POST['ISBN'], 'utf-8') != 10))) { echo "&lt;h1&gt;The ISBN you entered was too long or too short. ISBN's are 10 or 13 numbers in length.&lt;/h1&gt;"; showForm(); } else { generateLink_ISBN(); } } elseif (isset($_POST['title']) &amp;&amp; isset($_POST['aname']) &amp;&amp; ($_POST['aname'] != 'Author Name') | ($_POST['title'] != 'Book Title')) { if (isset($_POST['title']) &amp;&amp; isset($_POST['aname']) &amp;&amp; ($_POST['title'] == 'Book Title') &amp;&amp; ($_POST['aname'] != 'Author Name')) { echo "&lt;h1&gt;To search by author's name, you must also include the book title.&lt;/h1&gt;"; showForm(); } elseif (isset($_POST['title']) &amp;&amp; isset($_POST['aname']) &amp;&amp; ($_POST['aname'] == 'Author Name') &amp;&amp; ($_POST['title'] != 'Book Title')) { echo "&lt;h1&gt;To search by book title, you must also include the author's name.&lt;/h1&gt;"; showForm(); } else { generateLink_title(); } } else { showForm(); } } else { showForm(); } ?&gt; &lt;/body&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload