[HELP] mySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

[HELP] mySQL

Post by bla5e »

wtf? i cant post my code, i get an Error
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe fixing your code so it doesn't have INSERT INTO, DELETE FROM, .htaccess, Perl among others we've talked about before.... :roll:

viewtopic.php?t=27017
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Post by bla5e »

Code: Select all

<?php 
error_reporting(E_ALL); 
if (!empty($_POST&#1111;'submitted']) && $_POST&#1111;"submitted"] == 1)&#123; 

$alias = $_POST&#1111;"alias"]; 
$name= $_POST&#1111;"name"]; 
$position = $_POST&#1111;"position"]; 
$age = $_POST&#1111;"age"]; 
$email = $_POST&#1111;"email"]; 
$location = $_POST&#1111;"location"];
$map = $_POST&#1111;"map"];
$gun = $_POST&#1111;"gun"];
$quote = $_POST&#1111;"quote"];
$sensitivity = $_POST&#1111;"sensitivity"];
$resolution = $_POST&#1111;"resolution"];

$dbh=mysql_connect ("localhost", "***", "***") or die ('I cannot connect to the database because: ' . mysql_error()); 
mysql_select_db ("steve_onepurpose"); 
$sql = "SELECT * FROM `roster`"; 
mysql_query("INSERT " . "INTO `roster` (`id`, `alias`, `name`, `position`, `age`, `email`, `location`, `map`, `gun`, `quote`, `sensitivity`, `resolution`) VALUES ('', '$alias', '$name', '$position', '$age', '$email', '$location', '$map', '$gun', '$quote', $'sensitivity', '$resolution')"); 
$result = mysql_query($sql, $dbh) or die (mysql_error()); 
echo mysql_error(); 
echo "Roster Updated!!"; 
&#125; 

else 
&#123; 
//display the form 
?> 
<form action=rostercms.php method=post>
<table width="200" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>Alias</td>
    <td>Full Name </td>
    <td>Position</td>
  </tr>
  <tr>
    <td><input name="alias" type="text"></td>
    <td><input name="name" type="text"></td>
    <td><input name="position" type="text"></td>
  </tr>
</table>

<br>
Extended Profile (for profile page)
<table width="200" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>Age</td>
    <td>E-Mail</td>
    <td>Location</td>
    <td>Favorite Map</td>
    <td>Favorite Gun</td>
	<td>Quote</td>
	<td>Sensitivity</td>
	<td>Resolution</td>
  </tr>
  <tr>
    <td><input name="age" type="text" maxwidth="2" size="15"></td>
    <td><input name="email" type="text"></td>
    <td><input name="location" type="text" value="City, State"></td>
    <td><input name="map" type="text"></td>
    <td><input name="gun" type="text"></td>
	<td><input name="quote" type="text"></td>
	<td><input name="sensitivity" type="text"></td>
	<td><input name="resolution" type="text"></td>
  </tr>
</table>

<input type="hidden" name="submitted" value="1">
<input type="image" name=submitted src="submit.jpg" value="1">

<?php &#125; echo mysql_error(); ?>

Says its submitted, but DB is empty
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you try adding the usual "or die(...)" to your insert query?
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Post by bla5e »

got it, thanks
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Another Q: Undefined variable

Post by bla5e »

Notice: Undefined variable: s in /home/steve/public_html/onepurpose/ap/index.php on line 246

Notice: Undefined variable: s in /home/steve/public_html/onepurpose/ap/index.php on line 249

Notice: Undefined variable: s in /home/steve/public_html/onepurpose/ap/index.php on line 252

Notice: Undefined variable: s in /home/steve/public_html/onepurpose/ap/index.php on line 255

Notice: Undefined variable: s in /home/steve/public_html/onepurpose/ap/index.php on line 258

Notice: Undefined variable: s in /home/steve/public_html/onepurpose/ap/index.php on line 261

Code: Select all

<?PHP
		switch ($s) &#123;
		default:
			echo ("News");
		break;		
		case 'roster':
			echo ("Roster");
		break;		
		case 'matches':
			echo ("Matches");
		break;		
		case 'servers':
			echo ("Servers");
		break;		
		case 'sponsors':
			echo ("Sponsors");
		break;
		case 'about':
			echo ("About");
		break;
		case 'downloads':
			echo ("Downloads");
		break;
		&#125;
		?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$s wasn't set.
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Post by bla5e »

but I have the default: query...


how i fix?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

set it. Where does $s come from?
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Post by bla5e »

how do I set it? its just supposed to display data pertaining to that topic..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

find where ever you originally set it, and make sure it has a default value.
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Post by bla5e »

they all have a default value
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm not talking about the switch controls.. I'm talking about $s..
Post Reply