Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
ThePiston
Worker
Worker



Joined: Dec 22, 2004
Posts: 135

PostPosted: Mon Jan 24, 2005 7:10 pm Reply with quote

What's the script that you put at the top of your sql quesry so you can actually enter the database???

all i have is this
Code:
$result = mysql_query("SELECT * FROM drs_offices WHERE area = '$area'") OR die('MySQL Error:<br />' .mysql_error()); 

$num = mysql_num_rows($result);


[/quote]
 
View user's profile Send private message
PHrEEkie
Subject Matter Expert



Joined: Feb 23, 2004
Posts: 358

PostPosted: Mon Jan 24, 2005 7:33 pm Reply with quote

You need a connection string (usually one is provided in your MySQL manager once you create a DB and assign a user to it).

If you are calling that script from within Nuke or phpBB, then you include mainfile.php and the built-in SQL layer will be available to you. At that point, you add $db to the globals, and change your script to:
Code:
$result = $db->sql_query("SELECT * FROM drs_offices WHERE area = '$area'"); 

$num = $db->sql_numrows($result);


etc etc...

PHrEEk
 
View user's profile Send private message
ThePiston







PostPosted: Mon Jan 24, 2005 7:48 pm Reply with quote

something is terribly wrong with this code, can anyone clean it up?
Quote:

<?php
require_once("mainfile.php");

$result = $db->sql_query("SELECT *users_office1* FROM nuke_users IF users_location1 = '$area'");
("SELECT *users_office2* FROM nuke_users IF users_location2 = '$area'");
("SELECT *users_office3* FROM nuke_users IF users_location3 = '$area'");
("SELECT *users_office4* FROM nuke_users IF users_location4 = '$area'");
("SELECT *users_office5* FROM nuke_users IF users_location5 = '$area'");
$num = $db->sql_numrows($result);

if ($action==area) {
<center>There are $num offices in the $area section of the city</center>
while($row=mysql_fetch_assoc($result)) {
echo "<center>$row[user_office1] at $row[user_office2] $row[user_office3] $row[user_office4] $row[user_office5]</center>
}
mysql_free_result($result);
exit;
}

?>
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©