[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 03-25-2006, 12:40 PM   #1 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
[PHP | REP] Doesnt Fit Together

Hi,

I am making a tutorial submit system where the input page submits the information into a mqsql database, then there is a page in which shows this information, however it isnt working correctly, if someone could please check my code and correct it, REP WILL BE GIVEN.

I have checked my best and cant see any php function spelling errors or the wrong formatting, will be greatful if you can help.

Thanks

Steven

This is the display tutorial Page
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php
$connect = mysql_connect("localhost", "user", "password");
mysql_select_db("database", $connect);

$select = mysql_query("SELECT * FROM `tutorials`", $connect);
while($row = mysql_fetch_array($select, MYSQL_ASSOC)) {
    $id = $row['id'];
    $name = $row['name'];
    $email = $row['email'];
    $url = $row['url'];
	$url2 = $row['url2'];
	$WebsiteName = $row['WebsiteName '];
	$TutorialName = $row['TutorialName'];
    $description = $row['description'];

echo "
    <p>
    <strong>Tutorial Name:</strong> <a href="$url2;">$TutorialName</a><br />\n
	<strong>Submitted By:</strong> <a href="$url;">$WebsiteName</a><br />\n
    <strong>Description:</strong> $description
    </p>
";
}
?>

</body>
</html>
This is the data collection page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<p>
<form action="process_data.php" method="post">
   <input type="text" id="name" name="name" /> Name<br />
   <input type="text" id="email" name="email" /> E-mail<br />
   <input type="text" id="TutorialName" name="TutorialName" /> Tutorial Name<br />
   <input type="text" id="WebsiteName" name="WebsiteName" /> Website Name<br />
   <input type="text" id="url" name="url" value="http://" /> Website URL<br />
   <input type="text" id="url2" name="url2" value="http://" /> Tutorial URL<br />
   <textarea id="description" name="description" rows="5" cols="30"></textarea>Short Description<br />
   <input type="submit" value="Submit" />
</form></p>
</body>
</html>
Here is the process code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$url2 = $_POST['url2'];
$description = $_POST['description'];
$TutorialName = $_POST['TutorialName'];
$WebsiteName = $_POST['WebsiteName'];

?>
<?php
require('functions.php');

$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$url = cleanUp($_POST['url']);
$url2 = cleanUp($_POST['url2']);
$description = cleanUp($_POST['description']);
$TutorialName = cleanUp($_POST['TutorialName']);
$WebsiteName = cleanUp($_POST['WebsiteName']);

if (empty($email)) {
   echo "<p>Sorry, 'e-mail' is a required field. Please try again:</p>";
   include('collect_data.php');
   exit;
}

$connect = mysql_connect("localhost", "user", "password");
mysql_select_db("database", $connect);

$sql = "INSERT INTO `tutorials` VALUES ('', '$name', '$email', '$url', '$url2', '$TutorialName', '$WebsiteName', '$description')";

if (mysql_query($sql, $connect)) {
   echo "Thank you $name, your Tutorial was inserted into the database.";
} else {
   echo "Sorry $name, your tutorial could not be stored.";
}
?>
</body>
</html>
And here is the mqsql table create code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?
$connect = mysql_connect("localhost", "useer", "password");
mysql_select_db("database", $connect);

$create = "CREATE TABLE `tutorials` (
   `id` INT NOT NULL AUTO_INCREMENT,
   `name` VARCHAR( 150 ) NOT NULL,
   `email` VARCHAR( 255 ) NOT NULL,
   `url` VARCHAR( 200 ) NOT NULL,
   `url2` VARCHAR( 200 ) NOT NULL,
   `description` TEXT NOT NULL,
   `websitename` VARCHAR( 200 ) NOT NULL,
   `tutorialname` VARCHAR( 200 ) NOT NULL,
   
PRIMARY KEY (`id`))";

if (mysql_query($create, $connect)) {
   echo "Table (and fields) created.";
} else {
   echo "Table (and fields) not created.";
}
?>
</body>
</html>

Last edited by SecondVersion; 03-25-2006 at 01:02 PM. Reason: Not a good idea to let everyone know your db name(s) and password(s)
Xyzer is offline  
Old 03-25-2006, 02:16 PM   #2 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of

Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Whats is wrong with it.. (I am too lazy to look for problems).. So lets narrow it down..

- Steve
__________________
I feel old.
iNod is offline  
Old 03-25-2006, 10:01 PM   #3 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
Well basically the problem is i get an error when i try to read the database, and the fields are wwrong like http://www.x6core.com/submit_data.php.
I get
Quote:
Originally Posted by Error
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/gibbons/public_html/display_data.php on line 26
Im not so sure what this means and hope im inserting it properly, please if someone can help becuase its urgent.
Xyzer is offline  
Old 03-25-2006, 11:01 PM   #4 (permalink)
 
BillyConnite's Avatar
 
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,107
47.00 NP$ (Donate)

BillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant future

Wildlife Parkinson's Disease Parkinson's Disease
The error is on the "display tutorial Page".

When you want to echo something that contains quotes i.e.
PHP Code:
echo "my name is "rhett" and your name is "john"";
You need to put a simple \ behind the quotes located inside the echo quotes. so the above would be:
PHP Code:
echo "my name is \"rhett\" and your name is \"john\"";
See

In your case you should also take away the ; you had at the end of the variables

So to fix yours, find:
Code:
    <strong>Tutorial Name:</strong> <a href="$url2;">$TutorialName</a><br />\n
	<strong>Submitted By:</strong> <a href="$url;">$WebsiteName</a><br />\n
and replace with:
Code:
    <strong>Tutorial Name:</strong> <a href=\"$url2\">$TutorialName</a><br />\n
	<strong>Submitted By:</strong> <a href=\"$url\">$WebsiteName</a><br />\n
Let me know if you have any probs.
Regards, Rhett.
__________________
<?php if(1===1){ $computer="fine."; }else{ $computer="broken."; } echo "Your computer is ".$computer; ?>
BillyConnite is offline  
Old 03-25-2006, 11:15 PM   #5 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
Its still going wrong on this page: http://www.x6core.com/submit_data.php
the fiels are all mixed up.
Xyzer is offline  
Old 03-25-2006, 11:18 PM   #6 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of

Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Change

PHP Code:
    $WebsiteName = $row['WebsiteName '];
    
$TutorialName = $row['TutorialName'];
To
PHP Code:
    $WebsiteName = $row['websitename'];
    
$TutorialName = $row['tutorialname'];
Your tables are not caps, also you had a space after websitename.

In PHP caps play a big part.
$Deal = 5;

If you do print "$deal"; you will get nothing.. If you do print "$Deal"; you will get 5.

- Steve
__________________
I feel old.
iNod is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 11:46 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85