Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
make an array $months = array(1=>'January', 2=>'February...);
-
The manual is a great resource: http://dev.mysql.com/doc/refman/4.1/en/group-by-functions.html#function_count
-
Should it be /images/ad_edit.gif instead of just images/ad_edit.gif Try using a full URL instead of a relative one. *shrug* sorry if I can't help, that's the only thing I can think of.
-
If each one is in a folder, you don't need the index.php stuff, and it will look nicer. site.com/kitchens/ SHOULD work the same as site.com/kitchens/index.php Why don't you define your Site's BASE url as a constant: define('SITE_URL', 'http://site.com/'); and then whenever you have a link do: print '<a href="'.SITE_URL.'kitchens/">';
-
What do you see when you view the source of the page? As in, right click in your browser & view source - not the PHP file.
-
[SOLVED] Simple help with a PHP echo to a confirmation page
Jessica replied to shaunmacie's topic in PHP Coding Help
On the processing page, save any variables you want to use on the next page to the session. Example: $_SESSION['name'] = $name At the top of every page add session_start(); Then on your confirmation page, use $name = $_SESSION['name']; -
Do you have Firefox set to not show images? I don't see a problem with the code.
-
Well you have opening PHP tags inside your HEREDOC syntax. What you've written is pretty confusing. I think you need to clean it up, I personally never use HEREDOC. Just change it to: elseif ($getlink == "personalDetail") { //personal details changing ?> <u><b>Your Personal Details</b></u><br /> And then at the bottom remove: pd; No need for it here.
-
I usually do it the last way MadTechie showed. I find it's cleaner and you might need to use $name later so why mess with $_SESSION['name'] every time
-
Short Tags is an ini setting. You need to enable it in your php.ini file.
-
If you still need to use $result, yes, just make it a new name. I'd name them something related. So for my user example, I was getting all the users in the database, so that result would be $users. Then if I want to get my...erm...items, I'd do $sql = "SELECT * FROM items"; $items = $db->execute($sql); I also have a class which handles the results, based on ADODB. If you want to use a class for your DB and don't feel up to writing your own, ADODB is a good one. But anyway here is the Result class - you're welcome to use it if you want. Class Result{ var $numRows; var $result; var $fields; function Result($rs=NULL){ if($rs){ $this->result = $rs; $this->numRows = mysql_num_rows($rs); } } function getRow(){ $this->fields = array(); if($this->numRows){ $this->fields = mysql_fetch_array($this->result); return $this->fields; }else{ return FALSE; } } } I actually took it a step farther. Say I have another class, and I want to use $db in it to make one of it's functions access the database. Well, I don't want to have to do global $db; in every function. So I wrote One more function which is not in a class: function dbExecute($sql){ global $db; //which is in config.php if(($db_result = $db->execute($sql)) === false){ $err = 'Query: '.$sql."\n".'SQL Error : '.mysql_error()."\nURL: ".$_SERVER['REQUEST_URI']; die($err); }else{ return $db_result; } }
-
dbo, I abstract so much stuff it's nuts. If I'm going to use it once, I know I'll use it again so I just make it a function or a class lol.
-
Try this: $userID = $_SESSION['Current_User']; $sql = "SELECT houses.*, cities.*, countries.* FROM houses, cities, countries WHERE houses.userID = $userID AND cities.cityID = houses.cityID AND cities.countryID = countries.countryID"; $GetHouses = mysql_query($sql) or die(mysql_error().' - '.$sql); Right off the bat I see you had a . at the end of your SQL query, that might have freaked it out Don't try to do everything in one line, it's okay to have 3 lines if it makes it less confusing. Easier to debug and maintain!
-
No problem!
-
Email script challenge? Needs some feedback.
Jessica replied to sayedsohail's topic in PHP Coding Help
Use Code Tags! [code.][./code] without the . -
Can you show us the error, and yes, they are.
-
if (date($i == date("d") && $month == date("m") && $year == date("Y")) if (date($i == date("d")) && $month == date("m") && $year == date("Y")) Missing a ). PS: You really should use {} in your conditional statements, what if you need to add another line in there and you forget to add them? Then you have to hunt down an error you're unsure about. It's good practice to add them by default.
-
Use Code Tags please! [.code][/code.] around your code without the periods.
-
A constant is like a variable except it cannot change. Using constants is basically a security thing. A function takes arguments and is used to run the same code over and over with different arguments. So here is an example of all of these (plus a class). Constants: (This is the config.php file) // Set the database type, server and credentials define('DB_USER', 'username'); define('DB_PASS', 'pass'); define('DB_DB', 'my_db'); define('DB_SERVER', 'server'); // Establish the DB connection $db = new DB(DB_DB, DB_USER, DB_PASS, DB_SERVER); $db->connect(); Excerpt from DB.php File which is a Class Class DB{ var $username; var $password; var $server; var $database; function DB($database, $username, $password, $server){ $this->database = $database; $this->username = $username; $this->password = $password; $this->server = $server; return TRUE; } function connect(){ $rs = mysql_pconnect($this->server, $this->username, $this->password); if($rs !== FALSE){ if(mysql_select_db($this->database) !== FALSE){ return TRUE; }else{ dieError('Could not select database.'); } }else{ dieError('Could not connect to server. '.mysql_error()); } } function execute($sql){ //Before doing a query, clear out the old one. $rs = mysql_query($sql); if($rs === FALSE){ dieError('Could not complete query.<br />Query: '.$sql.'<br />Error: '.mysql_error()); return FALSE; }else if($rs === TRUE){ return TRUE; }else{ $result = New Result($rs); return $result; } } } So now $db is my variable which contains the connection and all the info in the class. So when I want to run a query on another page, it has the config.php included in it, I just use $db. $sql = "SELECT * from Users"; $result = $db->execute($sql); I hope that actually helps and is not just confusing
-
Hi, pls tell me what functions/package to use for the following ?
Jessica replied to jd2007's topic in PHP Coding Help
As chronister said "It depends on what your wanting to do with them". -
Try this: $trophies = explode(",", $site_array[trophies]); print_r($trophies); and see what it shows.
-
I don't quite understand your question. The userID is in the session? So do this: $userID = $_SESSION['userID']; SELECT house.*, city.*, country.* FROM house, city, country WHERE house.userID = $userID AND city.cityID = house.cityID AND city.countryID = country.countryID.
-
Well, can a user like, abandon their house? In that case, you'd have to delete it from the DB, or assign the userID as 0. (That would mean you don't need that extra table - any house with UserID 0 has no user. Easy!) Anyway that is a way a house could have no owner. Up to you Good luck!
-
Good! Don't forget to mark it Solved