Page 2 of 3
Posted: Fri Feb 13, 2004 4:46 pm
by seeker2921
Well, All the script does is return me to the add entry link and it doesn't ever update the database..
Also, I contacted my host and asked if register_globals was turned off they said yes and when I asked them to turn it on they said I could do it myself with an .htaccess file?
Posted: Fri Feb 13, 2004 4:49 pm
by dethron
dethron wrote:For debugging purposes, use the following line :
echo $id;
So what is the value for $id?
Posted: Fri Feb 13, 2004 4:54 pm
by seeker2921
all that $id says is "showadd"
Posted: Fri Feb 13, 2004 5:01 pm
by dethron
Try to use following script and let me know the output.
1-) Create a test page name as test.php
2-) Fill inside with the following php code
Code: Select all
<?php
if($cm=="a")
echo "just a letter a";
else if($cm==1)
echo "the value is number one";
else if($cm == "me")
echo "it comes out witj two letter";
else if($cm == "1")
echo "the string filled with one.";
else
echo "cm has the value : $cm";
?>
3-) request the page with the following parameters.
Code: Select all
http://yoursite.com/test.php?cm=a
http://yoursite.com/test.php?cm=1
http://yoursite.com/test.php?cm=me
http://yoursite.com/test.php?cm=strange
4-) Send me the output for these four cases.
Posted: Fri Feb 13, 2004 5:06 pm
by seeker2921
1. just a letter a
2. the value is number one
3. it comes out witj two letter
4. cm has the value : strange
Posted: Fri Feb 13, 2004 5:16 pm
by dethron
Yes this is great, because as you may seem the idea is the same.
If this works, your code should also work..
Lets observe your code, and find the mistake
Just wait some little time.
Posted: Fri Feb 13, 2004 5:33 pm
by dethron
Can u post the latest draft of the code?
I dont know in what way you changed.
Posted: Fri Feb 13, 2004 5:37 pm
by seeker2921
admin.php
Code: Select all
<?
include('/home/oblivion/public_html/admin/inc/config.php');
$strPAGE=$_SERVER['PHP_SELF'];
if(!isset($id)){
echo('<a href=admin.php?id=showadd>Add Entry</a>');
}
elseif($id==showadd){
$date = date ("Y-m-d H:i:s");
echo"<html><body>
<form name='form1' method='post' action='$strPAGE'>
<p class='date'>Date:
<input name='date' type='text' value='$date' maxlength='20'>
</p>
<p class='topic'>Topic :
<input name='topic' type='text' size='90' maxlength='180'>
</p>
<p class='entry'>Entry:</p>
<p>
<textarea name='entry' cols='90' rows='20'></textarea>
</p>
<p>
<input type='submit' name='addentry' value='Submit'>
</p>
</form>
<p> </p></body>
</html>";
}
function addentry(){
global $table; //presuming table isn't posted, but is 'set' elsewhere
$query = "INSERT INTO $table VALUES ('NULL','{$_POST['date']}','{$_POST['topic']}','{$_POST['entry']}')";
echo('Entry Added');
}
?>
config.php
Code: Select all
<?
//Include strings
include('/home/oblivion/public_html/admin/inc/strings.php');
//MySQL Connection Var's
define('DB_NAME', 'oblivion_main');
define('DB_HOST', 'localhost');
define('DB_USER', 'oblivion_oblivio');
define('DB_PASS', 'digital1');
$table=("journal");
$url=('http://www.o-blivion.com/site/blog');
?>
Posted: Fri Feb 13, 2004 5:37 pm
by tim
dethron will you quit teasing the kid and give him some solid help? lol
Try this:
Code: Select all
$query = "INSERT INTO $table VALUES ('NULL','$date','$topic','$entry')";
Change to:
Code: Select all
$query = mysql_query ("INSERT INTO tablename (date table name,topic table name, entry table name) VALUES ('$date', '$topic', '$entry')");
mysql_query($query);
Posted: Fri Feb 13, 2004 5:38 pm
by dethron
dethron out.
Posted: Fri Feb 13, 2004 7:08 pm
by John Cartwright
tim wrote:dethron will you quit teasing the kid and give him some solid help? lol
Try this:
Code: Select all
$query = "INSERT INTO $table VALUES ('NULL','$date','$topic','$entry')";
Change to:
Code: Select all
$query = mysql_query ("INSERT INTO tablename (date table name,topic table name, entry table name) VALUES ('$date', '$topic', '$entry')");
mysql_query($query);
The point of these forums is to help people understand how things work and how they can do it on their own. I believe Dethron was very helpful in happening this guy understand the concept of using variables to load things. The person did not ask about his query, althought it was helpful for you to give him a better way to do it, so you infact did not give him any "solid help"
Posted: Fri Feb 13, 2004 7:12 pm
by tim
if you'd notice the "lol" after my smart comment, it meant I was just joking.
man everyone has to be so uptight anymore these days.
Sorry dethron, no harm meant.
Posted: Fri Feb 13, 2004 9:27 pm
by seeker2921
Thanks to all of you that are trying to help me figuare this.. But I am still clueless on why it wont work.. I've tried everything I know (and that isn't much) and I can't get it to work what so ever.. Any other ideas??
Posted: Sat Feb 14, 2004 1:24 am
by Michael 01
Double check what length you have each column in your SQL just to make sure its not set lower than those values defined in your script. Specifically your DATE area.
Secondly, be sure to use addslashes, and htmlspecialchars functions to your variables before the insert so that the data is inputted without possible corruption when you do get it working.
Posted: Sat Feb 14, 2004 1:28 am
by seeker2921
All the MySQL stuff is set up correctly.. The addentry code works fine when it isn' a function.. thats my only problem..