Jump to content

Problem with PHP code


outofthisworldpc

Recommended Posts

Hello,

I'm attempting to run this PHP script that'll create a table of data in a MySQL database. I can't use the VARCHARS option for most of the fields as there will be a lot of content written in the areas that read "TEXT". I'm too sure how to fix this script so it creates the SQL table properly so any help will be appreciated. When i run this as index.php on my server, an error comes up saying:

[i]"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 23"[/i]

I checked line 23 but am uncertain on what the issue is. The Script is below:

[quote]
<?php
$db_host = "localhost";
$db_user = "mypal";
$db_pwd = "ezine";
$db_name = "users";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
mysql_query('CREATE TABLE sections(
logo VARCHAR(100),
contact VARCHAR(100),
themeHeader VARCHAR(100),
lifeSolutionsArticle TEXT,
lifeSolutionsAuthor TEXT,
workSolutionsArticle TEXT,
workSolutionsAuthor TEXT,
featureArticle TEXT,
featureAuthor TEXT,
highlyRecommendedContent TEXT,
todaysActionContent TEXT,
lifeSolutionsContent TEXT,
lifeSolutionsAdtrack TEXT,
adSlot1 TEXT,
workSolutionsContent TEXT,        <---- Line 23
workSolutionsAdtrack TEXT,
adSlot1 TEXT,
featureContent TEXT,
featureAdtrack TEXT,
adSlot3 TEXT,
lighterSideContent TEXT,
copyrightContent TEXT') or die(mysql_error());
echo "Table created!";
?>
<html>
<head>
<title>Ezine Control Panel</title>
<style type="text/css">
<!--
.style1 {
font-size: 12px;
font-style: italic;
}
.style3 {font-size: 12px; font-weight: bold; }
.style5 {font-size: 12px; font-weight: bold; font-style: italic; }
-->
</style>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action="" method="post">
  <div align="center">
    <p><img src="../MyPal2_header.gif" width="620" height="94"></p>
    <p><strong>E-ZINE TEMPLATE WIZARD CONTROL PANEL</strong></p>
    <p><span class="style3">*Note: All text areas below are HTML enabled.* </span><br>
    </p>
    <p>
      Insert Logo HTML here: <br>
      <span class="style1">(Example: &lt;img src=&quot;http://www.sample.com/logo.jpg&quot;&gt;) </span><br>
      <input name="logo" type="text" id="logo" value="" size="50">
    </p>
    <p>Contact Information:<br>
      <input name="contact" type="text" value="" size="50">
      <br>
      <br>
      <strong>TABLE OF CONTENTS AREA:    </strong></p>
    <p>Theme Header Text: <br>
      <input name="themeHeader" type="text" value="" size="50">
      <br>
      <br>
Life Solutions Article Title:<br>
<input name="lifeSolutionsArticle" type="text" value="" size="50">
<br>
<br>
Life Solutions Article Author: <br>
<input name="lifeSolutionsAuthor" type="text" value="" size="50">
<br>
<br>
Work Solutions Article Title:<br>
<input name="workSolutionsArticle" type="text" id="work-solutions-article" value="" size="50">
</p>
    <p>Work Solutions Article Author:<br>
      <input name="workSolutionsAuthor" type="text" id="work-solutions-author" value="" size="50">
<br>
      <br>
Feature Article Title:<br>
<input name="featureArticle" type="text" value="" size="50">
    </p>
    <p>Feature Article Author:<br>
      <input name="featureAuthor" type="text" value="" size="50">
</p>
    <p>Lighter Side  Title:<br>
      <input name="lighterSide" type="text" value="" size="50">
</p>
    <p><strong>CONTENT AREA </strong></p>
    <p>Highly Recommended:<br>
      <textarea name="highlyRecommendedContent" cols="100" rows="3"></textarea>
</p>
    <p>Today's Action:<br>
      <textarea name="todaysActionContent" cols="100" rows="3"></textarea>
</p>
    <p>Life Solutions Article :<br>
      <textarea name="lifeSolutionsArticle" cols="100" rows="3"></textarea>
</p>
    <p>Life Solutions Ad-Tracker:<br>
            <span class="style5">(Example: &lt;a href=&quot;http://www.ecomincs.com/sampleadtrack.etc&quot;&gt;Click Here&lt;/a&gt;) </span><br>
      <input name="lifeSolutionsAdtrack" type="text" value="" size="100">
</p>
    <p>Advertisement Slot #1:<br>
      <textarea name="adSlot1" cols="100" id="ad-slot1"></textarea>
</p>
    <p>Work Solutions Article :<br>
      <textarea name="workSolutionsContent" cols="100" rows="3" id="work-solutions-content"></textarea>
</p>
    <p>Work Solutions Ad-Tracker:<br>
        <span class="style5">(Example: &lt;a href=&quot;http://www.ecomincs.com/sampleadtrack.etc&quot;&gt;Click Here&lt;/a&gt;) </span><br>
        <input name="workSolutionsAdtrack" type="text" id="work-solutions-adtrack" value="" size="100">
    </p>
    <p>Advertisement Slot #2:<br>
      <textarea name="adSlot2" cols="100" id="ad-slot2"></textarea>
    </p>
    <p>Feature Article :<br>
      <textarea name="featureContent" cols="100" rows="3" id="feature-content"></textarea>
</p>
    <p>Feature Ad-Tracker:<br>
        <span class="style5">(Example: &lt;a href=&quot;http://www.ecomincs.com/sampleadtrack.etc&quot;&gt;Click Here&lt;/a&gt;) </span><br>
        <input name="featureAdtrack" type="text" id="feature-adtrack" value="" size="100">
    </p>
    <p>Advertisement Slot #3:<br>
        <textarea name="adSlot3" cols="100" id="ad-slot3"></textarea>
    </p>
    <p>Lighter Side (Humor Article):<br>
      <textarea name="lighterSideContent" cols="100" rows="3" id="lighter-side-content"></textarea>
</p>
    <p>Copyright/Disclaimer Information :<br>
      <textarea name="copyrightContent" cols="100" id="copyright-content"></textarea>
<br>
      <br>
      <input type="submit" name="submit" value="Submit - Only Press this one time.">
    </p>
    <p><a href="http://www.mypalsystem.com/mypal-training/ezine-template-wizard/template.php" target="_blank">View Ezine </a><br>
    (View only after hitting submit button) </p>
  </div>
</form>
<?php
} else {
$szero = $_POST['logo'];
$sone = $_POST['contact'];
$stwo = $_POST['themeHeader'];
$sthree = $_POST['lifeSolutionsArticle'];
$sfour = $_POST['lifeSolutionsAuthor'];
$sfive = $_POST['workSolutionsArticle'];
$ssix = $_POST['workSolutionsAuthor'];
$sseven = $_POST['featureArticle'];
$seight = $_POST['featureAuthor'];
$snine = $_POST['lighterSide'];
$sten = $_POST['highlyRecommendedContent'];
$seleven = $_POST['todaysActionContent'];
$stwelve = $_POST['lifeSolutionsContent'];
$sthirteen = $_POST['lifeSolutionsAdtrack'];
$sfourteen = $_POST['adSlot1'];
$sfifteen = $_POST['workSolutionsContent'];
$ssixteen = $_POST['workSolutionsAdtrack'];
$sseventeen = $_POST['adSlot2'];
$seighteen = $_POST['featureContent'];
$snineteen = $_POST['featureAdtrack'];
$stwenty = $_POST['adSlot3'];
$stwentyone = $_POST['lighterSideContent'];
$stwentytwo = $_POST['copyrightContent'];
mysql_query("INSERT INTO `sections` (logo, content, themeHeader, lifeSolutionsArticle, lifeSolutionsAuthor, workSolutionsArticle, workSolutionsAuthor, featureArticle, featureAuthor, lighterSide, highlyRecommendedContent, todaysActionContent, lifeSolutionsContent, lifeSolutionsAdtrack, adSlot1, workSolutionsContent, workSolutionsAdtrack, adSlot2, featureContent, featureAdtrack, adSlot3, lighterSideContent, copyrightContent) VALUES ('$szero', '$sone', '$stwo', '$sthree', '$sfour', '$sfive', '$ssix', '$sseven', '$seight', '$snine', '$sten', '$seleven', '$stwelve', '$sthirteen', '$sfourteen', '$sfifteen', '$ssixteen', '$sseventeen', '$seighteen', '$snineteen', '$stwenty', '$stwentyone', '$stwentytwo')");
echo "Success! Your ezine content has been added! Hit The Back Button to view the Ezine below the Submit button.";
}
?>
</body>
</html></body>
</html>[/quote]

Tks,
Brad. :)
Link to comment
Share on other sites

Would be a help to know if you get the table made first and if so what are the values of each field. If you do not get the table made then at least it is clear that this is the first query.

Out of interest can you not have a main table with the user id that will then link to another table with this user data so you do not have to create the new table or is there some other reason such as the number of users you intend to have that means you are going for this route.
Link to comment
Share on other sites

"Line 23" is referring to the query not the script.
[code]
mysql_query('CREATE TABLE sections(
logo VARCHAR(100),
contact VARCHAR(100),
themeHeader VARCHAR(100),
lifeSolutionsArticle TEXT,
lifeSolutionsAuthor TEXT,
workSolutionsArticle TEXT,
workSolutionsAuthor TEXT,
featureArticle TEXT,
featureAuthor TEXT,
highlyRecommendedContent TEXT,
todaysActionContent TEXT,
lifeSolutionsContent TEXT,
lifeSolutionsAdtrack TEXT,
adSlot1 TEXT,
workSolutionsContent TEXT, 
workSolutionsAdtrack TEXT,
adSlot2 TEXT,
featureContent TEXT,
featureAdtrack TEXT,
adSlot3 TEXT,
lighterSideContent TEXT,
copyrightContent TEXT)') <-- line 23
[/code]
The closing brace was missing. You also probably meant to define adslot2 rather than adslot1 again on line 18.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.