Home > Archive > PHP Language > August 2005 > Need Help with php and Mysql
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need Help with php and Mysql
|
|
| Jeffrey D Moncrieff 2005-08-13, 4:59 pm |
| I am trying to create a data base for colleting date for my research
project. I have run in to a couple of problems and I need it fast ASAP I
need it to be able to add data and edit them and view the data form a public
site. I have not use mysql and php since 2003 I have created the date base
with 2 tables 1 for a Jump Menu and on for the content. The contents is in
a table called PR and I as soon as I enter the data and hit submit the web
brower go blank.
mysql> desc PR;
+-------------+--------------+------+-----+------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+------------+----------------+
| ID | tinyint(4) | | PRI | NULL | auto_increment |
| Title | longtext | | | | |
| Pubilcation | varchar(255) | YES | | | |
| Date | date | | | 0000-00-00 | |
| Edition | varchar(10) | | | | |
| Section | varchar(10) | | | | |
| Page | varchar(10) | | | | |
| AUTHOR | longtext | | | | |
| Source | longtext | | | | |
| Body | longtext | | | | |
+-------------+--------------+------+-----+------------+----------------+
10 rows in set (0.06 sec)
mysql>
The Other is Media it look like this
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| id | tinyint(3) | | PRI | NULL | auto_increment |
| Company | varchar(40) | | | | |
| Mediatype | varchar(6) | | | | |
| url | varchar(255) | | | | |
+-----------+--------------+------+-----+---------+----------------+
I created a include called config.php
Which look like this
<?php
$mysql_host ='localhost';
$mysql_user= 'jdmonc';
$mysql_pass = '5373988';
$mysql_database = 'HRC'
?>
_____
The add-news function look like this. <body>
<form Action="libary/postnews.php" Method="post">
<table width="90%" border="5" cellspacing="2" cellpadding="2">
<tr>
<td width="8%"> <h3>Title</h3></td>
<td width="92%"> <textarea name="Title" cols="78"
id="Title"></textarea></td>
</tr>
<tr>
<td> <h3>Pubilcation</h3></td>
<td> <select name="Pubilcation" id="Pubilcation">
</select></td>
</tr>
<tr>
<td> <h3>Edition</h3></td>
<td> <select name="Edition" id="Edition"
onChange="MM_jumpMenu('parent',this,0)">
<option value="Final">Final</option>
</select></td>
</tr>
<tr>
<td> <h3>Date</h3></td>
<td> <input name="Date" type="text" id="Date" size="20">
(YYYY-MM-DD)</td>
</tr>
<tr>
<td> <h3>Section</h3></td>
<td> <input name="Section" type="text" id="Section" size="15"></td>
</tr>
<tr>
<td width="8%"> <h3>Page</h3></td>
<td> <input name="Page" type="text" id="Page"></td>
</tr>
<tr>
<td> <h3>By</h3></td>
<td> <input name="AUTHOR" type="text" id="by" size="20"
maxlength="40"></td>
</tr>
<tr>
<td> <h3>Source</h3></td>
<td> <input name="Source" type="text" id="Source"></td>
</tr>
<tr>
<td> <h3>BODY</h3></td>
<td> <textarea name="Body" cols="78" rows="78" wrap="OFF"
id="Body"></textarea></td>
</tr>
<tr>
<td> <h3> </h3></td>
<td> <input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
<html>
_______
Postnews.php
?php
///Connect to database Server
include ('config.php')
$connection = mysql_connect($mysql_host,$mysql_user,$m
ysql_pass)
or die ("unable to connecct")
//Select Database
mysql_select_db ($myaql_database,$connection)
or die ("Unable to select Database")
echo "test"
$query = "INSERT INTO PR (Title, Pubilcation, Date, Edition, Section,
Page, AUTHOR, Source, Body".
" VALUES ('', $_POST["Title"], $_POST["Pubcation"], $_POST["Date"],
$_POST["Edition"], $_POST["Section"], $_POST["Page"], $_POST["AUTHOR"],
$_POST["Source"],$_POST[Body]));
//$result = mysql_qurey($query);
echo $query;
include 'closedb.php'
/?>
| |
| Stefan Rybacki 2005-08-14, 8:59 am |
| Jeffrey D Moncrieff wrote:
> I am trying to create a data base for colleting date for my research
> project. I have run in to a couple of problems and I need it fast ASAP I
> need it to be able to add data and edit them and view the data form a public
> site. I have not use mysql and php since 2003 I have created the date base
> with 2 tables 1 for a Jump Menu and on for the content. The contents is in
> a table called PR and I as soon as I enter the data and hit submit the web
> brower go blank.
>
>
> mysql> desc PR;
> +-------------+--------------+------+-----+------------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-------------+--------------+------+-----+------------+----------------+
> | ID | tinyint(4) | | PRI | NULL | auto_increment |
> | Title | longtext | | | | |
> | Pubilcation | varchar(255) | YES | | | |
> | Date | date | | | 0000-00-00 | |
> | Edition | varchar(10) | | | | |
> | Section | varchar(10) | | | | |
> | Page | varchar(10) | | | | |
> | AUTHOR | longtext | | | | |
> | Source | longtext | | | | |
> | Body | longtext | | | | |
> +-------------+--------------+------+-----+------------+----------------+
> 10 rows in set (0.06 sec)
>
> mysql>
> The Other is Media it look like this
> +-----------+--------------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-----------+--------------+------+-----+---------+----------------+
> | id | tinyint(3) | | PRI | NULL | auto_increment |
> | Company | varchar(40) | | | | |
> | Mediatype | varchar(6) | | | | |
> | url | varchar(255) | | | | |
> +-----------+--------------+------+-----+---------+----------------+
>
> I created a include called config.php
> Which look like this
>
> <?php
> $mysql_host ='localhost';
> $mysql_user= 'jdmonc';
> $mysql_pass = '5373988';
> $mysql_database = 'HRC'
> ?>
>
> _____
> The add-news function look like this. <body>
> <form Action="libary/postnews.php" Method="post">
> <table width="90%" border="5" cellspacing="2" cellpadding="2">
> <tr>
> <td width="8%"> <h3>Title</h3></td>
> <td width="92%"> <textarea name="Title" cols="78"
> id="Title"></textarea></td>
> </tr>
> <tr>
> <td> <h3>Pubilcation</h3></td>
> <td> <select name="Pubilcation" id="Pubilcation">
> </select></td>
> </tr>
> <tr>
> <td> <h3>Edition</h3></td>
> <td> <select name="Edition" id="Edition"
> onChange="MM_jumpMenu('parent',this,0)">
> <option value="Final">Final</option>
> </select></td>
> </tr>
> <tr>
> <td> <h3>Date</h3></td>
> <td> <input name="Date" type="text" id="Date" size="20">
> (YYYY-MM-DD)</td>
> </tr>
> <tr>
> <td> <h3>Section</h3></td>
> <td> <input name="Section" type="text" id="Section" size="15"></td>
> </tr>
> <tr>
> <td width="8%"> <h3>Page</h3></td>
> <td> <input name="Page" type="text" id="Page"></td>
> </tr>
> <tr>
> <td> <h3>By</h3></td>
> <td> <input name="AUTHOR" type="text" id="by" size="20"
> maxlength="40"></td>
> </tr>
> <tr>
> <td> <h3>Source</h3></td>
> <td> <input name="Source" type="text" id="Source"></td>
> </tr>
> <tr>
> <td> <h3>BODY</h3></td>
> <td> <textarea name="Body" cols="78" rows="78" wrap="OFF"
> id="Body"></textarea></td>
> </tr>
> <tr>
> <td> <h3> </h3></td>
> <td> <input type="submit" name="Submit" value="Submit"></td>
> </tr>
> </table>
> </form>
> <html>
> _______
>
> Postnews.php
>
> ?php
>
>
> ///Connect to database Server
> include ('config.php')
> $connection = mysql_connect($mysql_host,$mysql_user,$m
ysql_pass)
> or die ("unable to connecct")
> //Select Database
> mysql_select_db ($myaql_database,$connection)
> or die ("Unable to select Database")
> echo "test"
> $query = "INSERT INTO PR (Title, Pubilcation, Date, Edition, Section,
> Page, AUTHOR, Source, Body".
> " VALUES ('', $_POST["Title"], $_POST["Pubcation"], $_POST["Date"],
I guess you're running in errors here. " VALUES ('', $_POST[" <-- oops string closed?!
some for the following $_POST["...
> $_POST["Edition"], $_POST["Section"], $_POST["Page"], $_POST["AUTHOR"],
> $_POST["Source"],$_POST[Body]));
> //$result = mysql_qurey($query);
> echo $query;
> include 'closedb.php'
> /?>
>
>
>
>
>
>
|
|
|
|
|