Jump to content

blueman378

Members
  • Posts

    888
  • Joined

  • Last visited

    Never

Everything posted by blueman378

  1. hmm i deleted that and tried to set that column as the unique key and get: SQL query: ALTER TABLE `games` ADD UNIQUE ( `RId` ) MySQL said: Documentation #1062 - Duplicate entry '0' for key 1 ???
  2. hi guys i have a table that looks like this: CREATE TABLE `games` ( `gSwfFile` varchar(100) NOT NULL, `gName` varchar(100) NOT NULL, `gThumb` varchar(100) NOT NULL, `gDescription` varchar(100) NOT NULL, `gplays` smallint(5) unsigned NOT NULL default '0', `RId` smallint(5) unsigned NOT NULL default '0', `category` varchar(100) NOT NULL, `keyword` varchar(100) NOT NULL, UNIQUE KEY `gName` (`gName`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; now what i want is to add in a column called RId and have it auto incriment, however when i try i get.. #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key any ideas what i have to do?
  3. oh and btw, make sure you dont have a " " space at the start or end of your php pages, including any that you include
  4. and what about those people with a dynamic ip? there is no way to truly keep your user logged in forever but the most common way is to set the cookie to expire eg 10 years later, but this can still be gotten rid of when the user clears thier cookies,
  5. oh and what does that thing in your sig do? .. oh very clever
  6. thanks, so many simple things, guess im just too tired at the moment but i need to get it done
  7. hi guys, well heres the error, Error: Unknown column 'boo' in 'where clause' heres the code function doSomething() { global $cat; global $action; global $database; // delete script here $q = ("DELETE FROM gsubcat WHERE cName = $cat")or die("Your have an error because:<br />" . mysql_error()); $result = $database->query($q) or die("Error: " . mysql_error()); header("Location: Category manager.php?action=$action&cat=$cat&run=y");} } heres the url http://localhost/admin/catprocess.php?action=Delete&cat=boo heres the table exported, -- phpMyAdmin SQL Dump -- version 2.11.2.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Dec 25, 2007 at 10:14 PM -- Server version: 5.0.45 -- PHP Version: 5.2.5 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `game` -- -- -------------------------------------------------------- -- -- Table structure for table `gsubcat` -- CREATE TABLE `gsubcat` ( `cId` tinyint(3) unsigned NOT NULL auto_increment, `cName` varchar(50) NOT NULL, UNIQUE KEY `cId` (`cId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; -- -- Dumping data for table `gsubcat` -- INSERT INTO `gsubcat` (`cId`, `cName`) VALUES (1, 'Action / Adventure'), (2, 'Beat em up'), (3, 'Other'), (4, 'Puzzle'), (5, 'Racing'), (6, 'Retro'), (7, 'Shoot em up'), (8, 'Sports'), (20, 'boo'); any ideas? oh and merry xmas to you too red arrow btw the reason for so many questions is i am working on many parts of the site
  8. hi guys, well heres my code, header("Location: ../ . str_replace ('/', '_', $cat ) . .php?run=y"); unfortunatially it doesnt work, any ideas? The requested URL / . str_replace ('/', '_', Beat em up ) . .php was not found on this server.
  9. that doesnt work because it looks for a variable ad, i know this is the problem because if i have $a d i get hello d
  10. hi guys, as the title says im to tired to think really but heres my problem $a = hello; echo $ad; thats effectively what i have what result im trying to get it hellod, so how do i do it ah gotta love 39 hours work over 3 days when your meant to be part time...
  11. hi guys i have, <?php $action = $_GET['action']; $cat = $_GET['cat']; if ($action == "Browse") { function doSomething() { // browse script here echo "You Are Now Browsing"; } } else if ($action == "Delete") { function doSomething() { // delete script here echo "Delete Complete"; } } else if ($action == "Create") { function doSomething() { // delete script here $sql = ("INSERT INTO `game`.`gsubcat` (`cId`, `cName`) VALUES ('NULL','$cat')"); die("SQL:<br>$sql"); echo "$_GET[cat] Creation Complete"; } } else { function doSomething() { echo "No Action Specified!"; } } doSomething(); but when i run it using this url: http://localhost/admin/catprocess.php?action=Create&cat=Hello the output is SQL: INSERT INTO `game`.`gsubcat` (`cId`, `cName`) VALUES ('NULL','') any ideas? thanks
  12. hi guys i am linking to a page called catprocess.php via catprocess.php$action=Delete or catprocess.php$action=Browse you get the idea, anyway i was wondering how would i preform different functions based on the $action variable? eg we have a function called browse, and one called delete, if action=delete preform delete function else if action = browse preform browse funxtion thanks btw i know i can use else ect but im looking for a tidier way thanks
  13. hi guys, i have this code, <?php function $row[cName](){ global $database; $q = "SELECT * FROM " . Games . " WHERE category='$row[cName]' ORDER BY `gName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if( $num_rows == 0 ){ return '<font size="2">Games not found!</font>'; } /* Display table contents */ $content = "$num_rows"; } return $content; // You can echo $row[cName](); ?> btw $row[cName] is defined in a prior sql statment, anyway my question is is it possible to have the function name as the array results a thing it might be useful to know this code is included in this: $q = "SELECT cName FROM " . gsubcat . " ORDER BY `cName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if( $num_rows == 0 ){ return 'Cats not found!'; } ?><table border="1" cellpadding="3" cellspacing="0" ><tr><td><b>Name</b></td><td><b>Games Assigned</b></td><td><b>Actions</b></td> </tr><?php while( $row = mysql_fetch_assoc($result) ) { echo '<tr><td>'; echo $row[cName] ?></td> <td><?php include("gamecount.php"); ?> </td> <?php echo ' <td><a href="catprocess.php$action=Delete&$cat=' . $row['cName'] . '"> <img src="../images/Delete.png" alt="Delete" Title="Delete"></a><a href="catprocess.php$action=Browse&$cat=' . $row['cName'] . '"> <img src="../images/Browse.png" alt="Browse" Title="Browse"></a></td></tr>'; } ?></table> <br> <br> <?php //cat form end ?> the error i get is Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in C:\wamp\www\admin\gamecount.php on line 2 which i gather its saying it was expecting a solid value rather than a variable thanks
  14. hi guys well i modified it a bit so now i have, echo '<tr><td>'; echo $row[cName] . '</td> <td>'"; include("gamecount.php); echo </td> <td><a href="catprocess.php$action=Delete&$cat=' . $row['cName'] . '"> <img src="../images/Delete.png" alt="Delete" Title="Delete"></a><a href="catprocess.php$action=Browse&$cat=' . $row['cName'] . '"> <img src="../images/Browse.png" alt="Browse" Title="Browse"></a></td></tr>'; error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\wamp\www\admin\Category manager.php on line 86 oh and your code before worked, thanks so any ideas this time?
  15. hi guys well heres the codce echo '<tr><td>'; echo $row[cName] . '</td> <td>5</td> <td><a href="catprocess.php$action=Delete&$cat=' . $row['cName'] . '">' <img src="Delete.png" alt="Delete"></a></td></tr>'; heres the error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\admin\Category manager.php on line 88 88 is the bottom line there thanks
  16. well you could have it so that it links to a page, eg showstate.php?state=statename and have your php code on the page and then have your mysql query and the where statment can be $_get['$state'] or something similar
  17. or possibly change it with %20, do you think that would solve it?
  18. hi guys i have this problem i just noticed that the link prints the name perfect however it only prints the first word of the name in the actual url, and this causes it to on any names that are longer than one word to instead of having a link like beat em up its just beat, this would be fine but it means that this code <?php //gameform global $database; $q = "SELECT cName FROM " . gsubcat . " ORDER BY `cName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); ?> | <?php while( $row = mysql_fetch_assoc($result) ) { echo "<a href=".$row[cName].".php>".$row['cName']."</a> | "; } ?> does not work as the .php is not printed on any links longer than one word
  19. the id colum, so for example i have ids between 1-20, rand can generate large numbers so would i have a while mysql affected rows = 0 rerun the query? else run my code with the generated results? how would i go about this? thanks
  20. so say i had 20 results would it keep running till it found one that matched?
×
×
  • 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.