Can I see an example of something..
Moderator: General Moderators
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
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
3-) request the page with the following parameters.
4-) Send me the output for these four cases.
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";
?>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-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
admin.php
config.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');
}
?>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');
?>dethron will you quit teasing the kid and give him some solid help? lol
Try this:
Change to:
Try this:
Code: Select all
$query = "INSERT INTO $table VALUES ('NULL','$date','$topic','$entry')";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);
Last edited by tim on Fri Feb 13, 2004 5:38 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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"tim wrote:dethron will you quit teasing the kid and give him some solid help? lol
Try this:Change to:Code: Select all
$query = "INSERT INTO $table VALUES ('NULL','$date','$topic','$entry')";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);
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
- Michael 01
- Forum Commoner
- Posts: 87
- Joined: Wed Feb 04, 2004 12:26 am
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.
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.
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact: