-
Posts
4,362 -
Joined
-
Last visited
-
Days Won
11
Posts posted by Zane
-
-
look at the datatypes FLOAT, DECIMAL, and DOUBLE
-
Yes....
genious....it worked perfect
thanks
question....if I had used inner join, right join, or just join
would it had made any difference -
I hate asking for code but what would that look like
I knew I'd have to use a combination of UPDATE and SELECT but I couldn't get the syntax right
when I first tried it..I got the error
that there was more than one row returned.
a query like this
UPDATE course2 a SET curr = (SELECT b.id from curriculums b where b.prefix = a.curr) -
um.....bump
-
that's not true
people do it all the time.
[quote=From MySQL documentation]
The index can also be used even if the ORDER BY does not match the index exactly, as long as all of the unused portions of the index and all the extra ORDER BY columns are constants in the WHERE clause. The following queries use the index to resolve the ORDER BY part
SELECT * FROM t1
ORDER BY key_part1,key_part2,... ;
SELECT * FROM t1
WHERE key_part1=constant
ORDER BY key_part2;
SELECT * FROM t1
ORDER BY key_part1 DESC, key_part2 DESC;
SELECT * FROM t1
WHERE key_part1=1
ORDER BY key_part1 DESC, key_part2 DESC;
[/quote] -
If you look at your query you'll notice $id is empty
that's your problem
[quote]FROM playerlist WHERE id= ORDER[/quote]
have you made sure you put the value in the URL.
I notice you're taking it from $_GET
so make sure in your URL your saying
yourplace.com/thisphppage.php?id=7
or something like that -
tell me what this gives you
[code]$result = mysql_query($sql) or die("SQL Query: {wordwrap($sql)}br />Error because: " . mysql_error());[/code] -
you need to post the error it's giving you
on the $result line
put
$result = mysql_query($sql) or die("Error because: " . mysql_error()); -
I use Zend Studio...
it automatically closes your brackets for you, and keeps up with all your variables and functions/classes
so while you're typing it gives you suggestions.
It also doesn't work off Your PHP installation, it has it's own PHP parser, and you can choose between either php4 or php5
a really useful program -
Alright, I use the DUMP feature in phpmyadmin to get a textlist
and used Dreamweaver's regex feature to do close to what I needed..
I have it looking like this now
[code]
+------+-----------+-------------------------------------+
| curr | coursenum | name |
+------+-----------+-------------------------------------+
| aca | 115 | Success and Study Skills |
| aca | 118 | College Study Skills |
| aca | 120 | Career Assessment |
| aca | 220 | Professional Transition |
| acc | 115 | College Accounting |
| acc | 121 | Principles of Managerial Accounting |
| acc | 129 | Individual Income Taxes |
| acc | 131 | Federal Income Taxes |
| acc | 150 | Acct Software Appl |
| acc | 175 | Hotel and Restaurant Accounting |
| acc | 193 | Selected Topics-Forensic Accounting |
| aca | 215 | Ethics in Accounting |
| acc | 220 | Intermediate Accounting I |
| acc | 221 | Intermediate Accounting II |
| acc | 225 | Cost Accounting |
| acc | 269 | Audit and Assurance Services |
| acc | 292 | Selected Topics in Accounting |
| ant | 210 | General Anthropology |
| ant | 220 | Cultural Anthropology |
| ant | 221 | Comparative Cultures |
+------+-----------+-------------------------------------+
[/code]
Still trying to figure out to convert them to their respective indeces
any thoughts -
I need some help...
I have a list of around 800 college classes,with the description, course name, the hours, etc
[color=orange]-created from REGEXing the hell out of these straight HTML pages ... btw (ouch)
http://www.southwesterncc.edu/acadprog/desc/aca-bus.htm#aca[/color]
This is the way the courses table looks
[code]mysql> select id,coursenum, name from courses limit 10;
+----+-----------+-------------------------------------+
| id | coursenum | name |
+----+-----------+-------------------------------------+
| 1 | aca115 | Success and Study Skills |
| 2 | aca118 | College Study Skills |
| 3 | aca120 | Career Assessment |
| 4 | aca220 | Professional Transition |
| 5 | acc115 | College Accounting |
| 6 | acc121 | Principles of Managerial Accounting |
| 7 | acc129 | Individual Income Taxes |
| 8 | acc131 | Federal Income Taxes |
| 9 | acc150 | Acct Software Appl |
| 10 | acc175 | Hotel and Restaurant Accounting |
+----+-----------+-------------------------------------+[/code]
If you look at the coursenum field you notice it says the major a lot...
[quote]acc
acc
acc
acc
..
..[/quote]
I also have a table full of these things with their keys
[code]mysql> select * from curriculums limit 10;
+----+--------+---------------------+
| id | prefix | name |
+----+--------+---------------------+
| 1 | aca | Academic Related |
| 2 | acc | Accounting |
| 3 | ant | Anthropology |
| 4 | art | Art |
| 5 | aut | AUTOMOTIVE |
| 6 | baf | Banking and Finance |
| 7 | bio | BIOLOGY |
| 8 | bpr | Blueprint Reading |
| 9 | bus | Busniess |
| 10 | car | Carpentry |
+----+--------+---------------------+[/code]
maybe someone's caught on by now, but I can't figure how I would do this;
I want to create new field in courses.....easy
go through every record's coursenum field...add the corresponding curriculum id to the new field leaving just the numbers.....WHAT how..
I'm clueless here....
anyone have any advice or suggestions...I know I could make a PHP script to do this, with an array
but that would take quite a bit of processing power
My goal is to get it to look like this
[code]
+----+------------+-----------+-------------------------------------+
| id | curriculum | coursenum | name |
+----+------------+-----------+-------------------------------------+
| 1 | 1| 115 | Success and Study Skills |
| 2 | 1| 118 | College Study Skills |
| 3 | 1| 120 | Career Assessment |
| 4 | 1| 220 | Professional Transition |
| 5 | 2| 115 | College Accounting |
| 6 | 2| 121 | Principles of Managerial Accounting |
| 7 | 2| 129 | Individual Income Taxes |
| 8 | 2| 131 | Federal Income Taxes |
| 9 | 2| 150 | Acct Software Appl |
| 10 | 2| 175 | Hotel and Restaurant Accounting |
+----+------------+-----------+-------------------------------------+[/code] -
you got it backwards there........when you extend a class it just means your essentially including the class and all it's properties
not adding on to it......
so in your case, when you extend ircbot, you're not really including anything at all
-
how you getting internet........dial-up
-
that's not gonna work with single quotes....it'lll just echo the name of the variable.
I think what he was missing was
exhibits;
right before your last
?> -
I don't know exactly why you're DROP statement fails, but I'm almost sure that users is reserved somewhere in MySQL, maybe if you put backticks around it it would work, but nevermind that way anyway..
It's better to use the IF EXISTS method...example
[code]
DROP TABLE IF EXISTS `my_users`;
CREATE TABLE IF NOT EXISTS `my_user` (
......blah-blah-blah[/code]
[quote]And what about the fact that mysql_select_db does take 2 arguments? You only show one in your code. Is this correct? Thanks zanus![/quote]
[quote]Description
bool mysql_select_db ( string database_name [, resource link_identifier] )
[color=green]Notice the second argument is in brackets.
In most all programming syntax manuals, brackets mean optional.[/color]
Sets the current active database on the server that's associated with the specified link identifier. Every subsequent call to mysql_query() will be made on the active database.
Parameters
database_name
The name of the database that is to be selected.
link_identifier
The MySQL connection. [b]If the link identifier is not specified, the last link opened by mysql_connect() is assumed.[/b] If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.[/quote]
[b]EDIT: I MERGED YOUR TWO TOPICS TOGETHER SINCE THEY HAD TO DO WITH THE SAME QUESTION[/b] -
because cookies are stored on your computer
and if you're able to use serialize and unserialize to read it
so can anyone else...just by opening the cookie
or at least that's my idea of it.
it could be more than that -
check your router/modem configuration and make sure you have DMZ turned on for your IP
-
Probably the most asked question there is.
yes it's your SQL query
http://www.phpfreaks.com/forums/index.php/topic,95376.0.html
You need to switch your ORDER by and WHERE in your query
i.e
the Where condition should come before ORDER -
[quote]What purpose does the variable '$connection' serve?[/quote]
You're right on one note....
theoretically you don't have to assign the connection to a variable
once you initialize the function it does it's thing and connects like you want, which is all you want at that point.
But then you might want to error check.
when you run mysql_connect();
it will try to connect and if it does it....for the sake of less explanation..........it doesn't return FALSE.
that way later you can check your variable to make sure it's not FALSE to make sure you actually connected.
Also, suppose you had multiple MySQL servers.
I've never seen anyone do it, but you can assign a connection to a multiple variables....
that way you can say
select database A on this Server
and then select database Y on another Server.
otherwise, whenever you try to select a database with
mysql_select_db()
it just uses the default connection, or the ONLY connection you've made -
you STRINGified the rest of your code and exited PHP at the same time, that's why it doesn't work
look here
[quote]
<?php
//opens a new file and writes the database connection string to it then closes this new file
$connectfile = fopen("dbconnect.php","w");
fwrite($connectfile, [size=16pt]"[/size] [b]<-- You forgot to close your quote[/b]
<?php \$dbh=mysql_connect (\"$serverurl\", \"$nameofuser\", \"$passofuser\")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db (\"$databasename\");?>[size=16pt]"[/size]); <--So it thinks this is the end of the string I.E. your argument for fwrite
[/quote]
and also you, for some reason opened another PHP tag (labeled in green above)
change that snippet to this and you should be fine
[code=php:0]
<?php
//opens a new file and writes the database connection string to it then closes this new file
$connectfile = fopen("dbconnect.php","w");
fwrite($connectfile, "");
$dbh=mysql_connect ($serverurl, $nameofuser, $passofuser)
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($databasename);
[/code] -
yes OR exists in PHP
you can also use || -
When you include a file, especially PHP files
you don't use the URLs
give a relative location
like
require_once "../includes/dbconnect.php";
reason for that is to keep people from stealing other people's scripts -
If you're storing your dates as YYYY/MM/DD
then you can do this
[code]$fromDatabase = "2006/11/13";
//Convert it to UNIX timestamp
$toUNIX = strtotime($fromDatabase);
//Convert it to your desired date format using the date() function
//Military Time
$newDate = date("H:i A", $toUNIX);
//12-hour Time
$newDate = date("h:i A", $toUNIX);[/code] -
[quote]1. My sql connections are correct, as they work [size=12pt]everywhere else.[/size][/quote]
by everywhere else do you mean another computer.
If you're trying to log into your MySQL server from somewhere else
you must make sure that that MySQL server allows that IP, or at least the range or domain.
If that's not the case double check your connection anyway, cuz it does say you're not issueing a password
[code]using password: NO[/code]
MySQL/PHP Math Problem - Greater than or less than $variable problem.
in MySQL Help
Posted
and from you're first example.....10 is the highest...newtotal will ever get
so make $newtotal start at 10
and decrement it gradually
[code=php:0]
$newtotal = 10;
if ($total > 15)
$newtotal -= 5;
if($total > 21)
$newtotal -= 5;
echo $newtotal;
[/code]