Jump to content

Database query isn't working.


mischievousx3

Recommended Posts

I'm having a problem with adding icon/avatar to my database..this is a submit form where I just submit the avatar url. I don't know how to change the submit link from avatar_add.php?mode=submit to index.php?mode=submit&x=avatar_add.

http://www.graphics.allmerk-noplay.com/index.php?x=avatar_add

 

 

<?php
$host =""; // host name
$user =""; // user
$pass =""; // password
$dbase =""; // database name

// connect to the server
mysql_connect("$host","$user","$pass");
// and select the database
mysql_select_db($dbase);

$mode=$_GET["mode"]; // get the mode
$QUERY_STRING = 'x=avatar_add';

if(!isset($mode) || empty($mode)) // if mode is empty, switch to case index
{
$mode='index';
}

switch($mode)
{

case 'index'; // displays the form
?>


<form method="post" action="avatar_add.php?mode=submit">
Avatar URL:<br>
<input type="text" name="avatar_url" size="30"><br><br>
<input type="submit" value="Submit">


<?php
break;

case 'submit'; // form processing mode

$avatar_url=$_POST["avatar_url"];

// check for empty fields
if(empty($avatar_url))

{
echo "Error! Please go back and fill in all the required fields!";
// if you have a footer include, insert it before the die statement
die; // stops the script from executing the rest of the code
}

// let's get the date in YYYY-MM-DD format
$date = date("Y-m-d");

$query="INSERT into icons_db (id,avatar_url) VALUES ('','$avatar_url')";
$result=mysql_query($query) or die ("Couldnot execute query: $query." . mysql_error());

if($result) // if mysql query successful
{ echo "Thank you! The avatar has been added to or database."; }

break;

}

?> 

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.