jedipi
Apr 4 2005, 12:58 PM
| | In PHP, if the mysql database server cannot be connected, for example database server is handed or turned off, an error message will be displayed: Warning: mysql_connect(): Unknown MySQL Server Host "mysql.example.com" ...
My question is how to not display this warning message? or can I customise the error message? if so, how?
Thank you. |
Reply
vujsa
Apr 4 2005, 01:12 PM
This should suppress most messages. Unless there is a die() message coded in and there probably is. @mysql_connect(): Look for mysql_connect(); and change to: @mysql_connect() or die("Sorry Server Error"); however, you may want to investigate why you are getting an error message. Hope this helps! vujsa
Reply
vizskywalker
Apr 4 2005, 06:07 PM
PHP also provides a mysql function to determine the error. The function is as follows: mysql_error(). It takes no parameters. If you want to use this information, you can either store it to a file or display it on the webpage. Follow this code: CODE $variable = mysql_connect(); //This assigns the connetion to $variable, on failure $variable is null and there is no error message if (!$variable){ //If variable doesn't exist, there was a failure //code to either display the error or save it to a file die(); //end the script }
Reply
jedipi
Apr 5 2005, 02:04 AM
Problem fixed... thank you so much. here is my statement: $db_link = @mysql_connect($db_host,$db_username,$db_password) or die("Cann't Connect to Database.\n");
Reply
vizskywalker
Apr 5 2005, 02:21 AM
That'll do it. Whenever you need to debug a script, remember the die() function. Most scripting languages have it and it is very useful.
Reply
Similar Topics
Keywords : php display mysql connection error mysql message- How To Make A PM (Personal Message) System?
- (Should I Store The Data In A Database?) (5)
Hey! I just wanted to know, if I want to make a PM system, should I store the PMs in a database or
how should I do it? And if I should store them in a database, how do I do that. Because I have
acctually no idea, if I should create 50 tables to store 50 messages /tongue.gif"
style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> (And a little OT question
). How can i change the timestamp into real date?...
Php Configuration Error?
- (6)
Important: Basics Of Using PHP And MySQL
- (10)
I generally notice confusion with new users to PHP and or MySQL and first of all I believe that
unlike HTML which is automatically associated with a IE browser in a Microsoft system. HTML is
automatically rendered with whatever browser is the default browser, be it Internet Expolrer Firefox
Netscape or any other browser that has been set. PHP is a different matter to view the output of a
PHP file it must be run on a webserver, and if you do not have one set up on your local PC it simply
will not work. (Note serverside langauge requies a server) HTML is client side and ...
[PHP + MySQL] Encrypting Data
- To protect the password of your DB, for example. (11)
Hi! This is my 2nd code of PHP + MySQL. This code is VERY simple: it encript the data in the MySQL
DB. Here we go! ------------------------------------------------------------------------ CODE
$password = "abc"; $new_password = md5($password); echo $new_password; ?> The password "abc"
was codfied using md5() This will be: 900150983cd24fb0d6963f7d28e17f72 CODE $normal_pass =
"abc"; $encripted_pass = "900150983cd24fb0d6963f7d28e17f72"; if(md5($normal_pass) ==
$encripted_pass) echo "Login Sucessful!"; else echo "Incorrect password."; ?> This c...
Cant Find The Error
- (2)
In this code I want to retrieve the energy and max energy of a players account, then add 8% to
energy of maxenergy, hen if energy is bigger than maxenergy, energy is then made equal to maxenergy.
Then the database is updated. I don't understand why it's not working.
$query=mysql_query("SELECT MAX(id) as maxid FROM `accounts` LIMIT 1"); $row =
mysql_fetch_assoc($query); $id = $row ; $query = "SELECT * FROM `accounts`";
$result=mysql_query($query); while ($row=mysql_fetch_assoc($result)) { $energy = $row ; $maxenergy
= $row ; } for($i=1; $i $query = "SELECT...
PHP & MySQL: Displaying Content From A Given ID
- (6)
Okay so I got this sample link (not working): http://www.acosta.com/joo.asp?id=654 Now suppose
I have a PHP file that would use MySql in order to get all values in the row where id 654 is found.
Here's a sample DB: Table: demnyc ______________________________________ | id |
Name | Age | Email | *----------------------------------------------------* | 1
| Albert | 17 | no email |
*----------------------------------------------------* | 2 | YaPow | 888 |
no email | |__________...
Need Help With A PHP - MySQL Registration Script
- Wont INSERT into the database (13)
hey well can some one helpme make this code work it won't INSERT INTO THE DATABSE CODE #
register1.php # common include file to MySQL include("DB.PHP"); $Username=$_POST ; $Password=$_POST
; $Name=$_POST ; $Last=$_POST ; $Sex=$_POST ; $Month=$_POST ; $Day=$_POST ; $Year=$_POST ;
$Adresse=$_POST ; $City=$_POST ; $State=$_POST ; $Zipcode=$_POST ; $Country=$_POST ; $Phone=$_POST ;
$Email=$_POST ; $Father_Name=$_POST ; $Mother_Name=$_POST ; $Parent_Phone=$_POST ;
$Parent_Email=$_POST ; $Level=$_POST ; $Academic=$_POST ; $Image_Link=$_POST ; $sql9="INSERT INTO
U...
Letting Users Add Mysql Data With Php
- (1)
I'm curious as to the best methods of letting users submit data to a MySQL database, displaying
that data, and removing any unwanted tags etc. from it. Currently, there's a handful of PHP
functions that I know of to help with this: mysql_real_escape_string() - perhaps the best known
and most commonly used function, it should be used in pretty much any MySQL query. It escapes
characters that have SQL significance. QUOTE(php.net) ...which prepends backslashes to the
following characters: \x00, \n, \r, \, ', " and \x1a I like to think I made a pretty...
Mysql Question(inserting Number From A Textfield)
- (3)
Hey! I am trying to do a "Admin give EXP script". But I can't make it work. The value is not
updating, but the update query is correct.( I think:P) I think the fault is here: CODE
$expcomp=$givexpp += $givexp; The $givexp is the variable for the amount of Xp the admin wants
to give. the $givexpp is the variable for the user info (in this case, the experince he already
have). The datatype for the XP in the database is INT. So I have no idea if it can take data from a
normal textfield. If you need to see all the code, here you go: CODE session_start();...
Making A Link = Mysql_query
- (8)
Hey! I will try to make this as clear as possible. how can I make the following. I have a list,
of all members on my site. If I press on a members name(link), I will come to his profile. To come
to his profile, I need to get out some vaule from the database, but to get out some value from the
database, I must tell the code, how it should know who the user is (hard to understand?). To do
that, I must add a mysql_query in the code ( I think), like "SELECT user FROM dbname WHERE
user=link".. This is just how I think it works. I know it is kinda wrong.. but I don't k...
Making Something In Mysql Happen Only Once
- (10)
Hey! I know I am asking alot. But much is happening theese days. Sorry if I disturb with my
questions. The thing I am trying to do is: Ex. If the user becomes level 2, he should get 5 skill
points. I can't do this: CODE if($userlevel=5){ mysql_query("UPDATE user SET skillpoints
=$points+5");} because then it would update everytime the code was loaded. I hope you understand
what I am trying to do. If not, tell me /smile.gif" style="vertical-align:middle" emoid=":)"
border="0" alt="smile.gif" /> and i'll try to explain better. Thanks //Feelay...
Php Error-where To Put "?>"
- (2)
lol....lately i have many problems in writing my scripts and i dont know if i should create post
only for purpose so ppl can help me or should i create many post like i am doing right now...i am
NOT making this to get many credits...i am doing it because i need help and many people here help
me! CODE if ($_GET !='race'){ Who do you wanna race? Derbi Senda 50
Honda NS 50 R Suzuki ZR 50 Yamaha DT 50 MX Aprilia RS 50 - ?
} i have this code...if i put after it i get QUOTE Parse error: syntax...
Warning: Mysql_result(): Supplied Argument Is Not A Valid Mysql Result Resource In ...
- This Is for My attack Script. (4)
Hey. I am making a "Version 2.0" For my attack script, but I can't make it work. This is the
error I am gettin: Warning: mysql_result(): supplied argument is not a valid MySQL result resource
in And here is the code: CODE $dbQueryHealth = mysql_query("SELECT temphealth FROM
characters WHERE user =". $_POST .""); $currentHealth = mysql_result($dbQueryHealth, 0);
$dbQueryExp = mysql_query("SELECT exp FROM characters WHERE user = ".$_POST ."");
$currentExp = mysql_result($dbQueryExp, 0); I have checked the PHP Manual,...
Warning: Mysql_num_rows()
- What is the error :S (1)
Hey! I've made a register script.. Some time ago it worked. And I ain't sure if I changed
something since then.. The error I am getting is this: Warning: mysql_num_rows(): supplied argument
is not a valid MySQL result resource in /home/feelay/public_html/regcheck.php on line 31 Here is
the code on theese lines: CODE $sqlCheckForDuplicate = "SELECT username FROM user WHERE username
= '". $username ."'"; if( mysql_num_rows( mysql_query(
$sqlCheckForDuplicate ) ) == 0 ) { $sqlRegUser = "INSERT INTO ...
Anyone Know Of A Really Good Mysql Class?
- Looking for something easy but full featured. (4)
Generally speaking, when I write a script, it either utilizes the MySQL class of the parent system
(like Mambo or Joomla) or I use basic functions and snippets to perform the database queries I need.
I really like the Joomla database class as it allows you to simply pass a regular query string to
it and the data is returned without the need for extra work! The Invision Power Board (IPB)
database class which is what is used for this forum is kind of a pain to use since it wants the
query string in a non-MySQL standard format. Nonetheless, it does work and I could use i...
Php Math Error
- (4)
I cant get php to do simple math. Anyway
I need to run a math problem from the mysql database (dont ask why). So lets say I have an entrie: 5
+5. I get it from my db then eval it but nothing happens? How could I make it so that it runs the 5+
5 rather then just displaying it? Thanks, Sparkx Also: I have no clue if it is just my browser or
what but my post breaks to boarder for some odd reason?...
Unexpected Error
- Undefined variable??? (2)
Is this script correct? index.php : CODE if (isset($_COOKIE )) $_GET =
$_COOKIE ; else setcookie("disp_name", Anonymous, date()+99); ?>
Display Name - DZN
Dislpay Name: name="name" />
proccess.php : CODE Proccessing Request... Please wait...
setcookie("disp_name", $_GET , date()+99); ?> main.php : CODE function customErr...
Extracting Mysql Maths Using Php
- (2)
Right, this is a really simple thing and it has me completely stumped. I'm working on this mini
maths function and for some reason i cannot seem to do some simple math process using mysql. This is
the code: (php btw), now assume that $date is actually a defined mysql date variable already
successfully extracted. $sql = mysql_query("SELECT TO_DAYS('CURDATE()') -
TO_DAYS('$date')"); while ($row = mysql_fetch_array($sql)){ $diff = $row ; } Can
anyone spot what im doing wrong becuase im just thrown by it....
Too Many Connections?
- mysql_connect() (4)
I uploaded my PHP game yesterday, and most of my friends tried it out. After a while, I tried to
play as well but it said that mysql_connect() had too many connections already. Can anyone tell me
how to increase the amount of connections or maybe the total amount of connections allowed?...
Sql Injection Prevention (passing Numerical Data Across Pages).
- PHP/mySQL (9)
Even if your building something as simple as a basic news page for your website, if your passing
along url variable strings like (mysite/index.php?page=1), you may be vulnerable to SQL injection
attacks. For cases like these (passing numerical data in url strings), I have a handy dandy little
function to thwart these attempts silly: CODE // For checking if value is a number, if not
return 1. function isNum($val) { if (!is_numeric($val)) { $val = 1; } return ($val); } I
have this function, within my functions.php file, which I use as an include in files w...
Php/mysql And Manual Page Caching?
- (4)
I am hopefully about to attempt this on the news page of my new site. Every bit counts as far as
I'm concerned and not having "news" portion of my news page re-php and re-mysql everything where
there is no chance seems like a waste. I'm looking for good articles, information or tips on
the process (if I fail to find any good information as I'm looking through now). The way I see
it right now, I have most of my page split up in header, content (some static html in here before
dynamic contend and then a little more static html to close it off) and then a foo...
Php Mysql Errors
- Fetching arrays (2)
I am deciding to make a Multiplayer Online RPG type game. I will be building it off of PHP and MySQL
to ensure makimum compatibility with Astahost's services (and it makes it easier /wink.gif"
style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />). I have a database setup with
1 table to hold user data and I have the login system setup properly as well as the registration
form (obviously). All games of course have something similar to gold, units and points. Because
this is a turn-based game, I have turns. Now for the problem: I am trying to echo ...
Error On Submit Page
- (10)
I am writing a new submit page for one of my sites and am doing a few things to stretch my
experience. I am getting an error (naturally.) Here is part pf the page where the error might be:
CODE //Check to see if the web page called itself if (strtoupper($action) == "CHECK") {
//The web page called itself, so run the error checking code //Declare a variable to
hold the error messages $error = ''; // variable names: name, cat, sub_cat, url,
date, status, email, other, area_code, city $name = $_POST ; $cat = $_P...
How To Show Serial Nums In PHP Table For Contents Of MySQL DB
- Serial Numbering for output contents of mysql in php table (4)
Hello there, I'm looking for some education. How would you show the serial numbering for
outputted contents of mysql database. I used a table created in PHP to output content (i.e. an
alumni database) and I created a column for S/N, so that at a glance anyone can tell how many
members have registered. Thanks house. Neyoo...
Re-order MySQL Table
- (11)
Hello you all, I've got a question /smile.gif" style="vertical-align:middle" emoid=":)"
border="0" alt="smile.gif" /> Let's say I have a database width the table "news". It contains
about 10 items which is ordered by the field "id". Now from my admin page i do this: CODE
mysql_query("DELETE FROM news WHERE id=4"); ?> And a few days later i do: CODE
mysql_query("DELETE FROM news WHERE id=7"); ?> Now there are two gaps in the table => 1, 2, 3,
5, 6, 8, 9, 10 (no 4 and 7). It want to reallocate the whole table to fill the gaps like this => 1,
2,...
Need MySQL Alternative To The Syntax "or die()"
- (8)
Hello again /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
I'm facing a problem with PHP and MySQL... I want, when a MySQL error occurs, to let the script
continue. Here's the script: CODE $query = "SELECT * FROM menus ORDER BY id ASC";
$menus_result = mysql_query($query) or die("Error!"); while( $menu=mysql_fetch_array($menus_result)
) { echo $menu ." "; } Now if the table "menus" doesn't exist, this would echo "Error!"
where it's placed and terminate the whole script. But I want it to echo "Error!" and...
Got A Wee Error - Can You Help?
- (13)
I'm taking a PHP course at college and am working on an assignment. There's no database
involved. I've declared my variables from a submit form on another page, and on the page
I'm working on I'm trying to bring them up in a table. But my start-table command is
outputting an error. Here's the code relating to where the error is: CODE //Get First
Item if (isset($_GET )) { $item_1_product = $_GET ; } else {
$item_1_product = ""; //Default value if data missing } if (isset($_GET ))
{ ...
E-mail List Error
- (4)
I just coded this e-mail list, it works well for entering data into database, but if user leaves
the field blank or adds an already exist e-mail it gives him the error message and stops loading the
rest of the page. CODE // Connects to your Database mysql_connect("localhost", "my_username",
"mypassword") or die(mysql_error()); mysql_select_db("Database name") or die(mysql_error()); //This
code runs if the form has been submitted if (isset($_POST )) { //This makes sure they did not leave
any fields blank if (!$_POST ) {die(' No e-mail added '); } ...
Need Help With Php/mysql And Web Servers Such As Asta's.
- (4)
Within my site I have built my own basic forum using PHP/Mysql, I always test locally now both using
EasyPHP and WAMP5 which both give me no problems what so ever. But when I tryed to run the exact
same code on Asta's hosting services (and possible another I used to use) when creating a new
thread or adding a reply to an existing one it *sometimes* adds an additional thread/reply as a
Guest (someone not signed in) with an empty message. This would lead me to believe that somehow the
page is being refreshed and the variables sent to the database update php file are ...
How Do You Create A Secure Loging?
- with PHP and mySQL (4)
I've read a few articles, and looked up the code of certain files and some of them seem to work
differently. I'm trying to create a login script, which would require PHP and mySQL to run,
however, I'm not quite sure how to approach it since I'm only just learning PHP. I'd
like to know, what is the most secure and effective login? I've heard you can add a salt to
encrypted passwords, etc, and well as using sessions (sid). It's just like to know what methods
are best for creating a secure login script. Thank yo ufor readin this. ...
Looking for php, display, mysql, connection, error, mysql, connect, message
|
*SIMILAR VIDEOS*
Searching Video's for php, display, mysql, connection, error, mysql, connect, message
|
advertisement
|
|