473,511 Members | 15,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql_select_db Errors

201 New Member
hello -

I'm inserting the records one after another into a seperate table.

and it just errors says:
warning: mysql_select_db(): supplied argument is not a valid mysql-link resource

heres the code

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('/opt/lampp/htdocs/domain/Connections/Users_Schema.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  40.    mysql_select_db($database_user, $Schema);
  41.  
  42.  $insertSQL = sprintf("INSERT INTO user (user_Id, UEA, UEAP) VALUES (null, %s, %s)", 
  43.                        GetSQLValueString($_POST['user_Id'], "int"),
  44.                        GetSQLValueString($_POST['UEA'], "text"),
  45.                        GetSQLValueString($_POST['UEAP'], "text"));
  46.  
  47.     mysql_select_db($database_uname, $Schema);                      
  48.     $insertSQL1 = sprintf("insert into uname (uname_Id, user_Id_fk, Fname, Lname) values ( LAST_INSERT_ID(), LAST_INSERT_ID(), %s, %s )",                                                                                   GetSQLValueString($_POST['uname_Id'], "int"),
  49.                        GetSQLValueString($_POST['user_Id_fk'], "int"),
  50.                        GetSQLValueString($_POST['Fname'], "text"),
  51.                        GetSQLValueString($_POST['Lname'], "text"));
  52.  
  53.     mysql_select_db($database_uzip, $Schema);
  54.     $insertSQL2 = sprintf("insert into uzip (uname_Id_fk, uzip_Id, Zip) VALUES (LAST_INSERT_ID(), null, %s,)",                                                                     GetSQLValueString($_POST['uname_Id_fk'], "int"),
  55.                        GetSQLValueString($_POST['uzip_Id'], "int"),
  56.                        GetSQLValueString($_POST['Zip'], "text"));
  57.  
  58. //----------------- db name ------------- db connection
  59.  
  60.   $Result1 = mysql_query($insertSQL, $Schema) or die(mysql_error());
  61.  
  62.   $Result2 = mysql_query($insertSQL1, $Schema) or die(mysql_error());
  63.  
  64.  
  65.   $Result3 = mysql_query($insertSQL2, $Schema) or die(mysql_error());
  66.  
  67. }
  68. ?>
  69. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  70. <html xmlns="http://www.w3.org/1999/xhtml">
  71. <head>
  72. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  73. <title>Untitled Document</title>
  74. </head>
  75. <body>
  76. <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  77.   <table align="center">
  78.     <tr valign="baseline">
  79.       <td nowrap="nowrap" align="right">Email Address:</td>
  80.       <td><input type="text" name="UEA" value="" size="32" /></td>
  81.     </tr>
  82.     <tr valign="baseline">
  83.       <td nowrap="nowrap" align="right">Password:</td>
  84.       <td><input type="password" name="UEAP" value="" size="32" /></td>
  85.     </tr>
  86.     <tr valign="baseline">
  87.       <td nowrap="nowrap" align="right">First Name:</td>
  88.       <td><input type="text" name="Fname" value="" size="32" /></td>
  89.     </tr>
  90.     <tr valign="baseline">
  91.       <td nowrap="nowrap" align="right">Last Name:</td>
  92.       <td><input type="text" name="Lname" value="" size="32" /></td>
  93.     </tr>
  94.     <tr valign="baseline">
  95.       <td nowrap="nowrap" align="right">Zip:</td>
  96.       <td><input type="text" name="Zip" value="" size="32" /></td>
  97.     </tr>
  98.     <tr valign="baseline">
  99.       <td nowrap="nowrap" align="right">&nbsp;</td>
  100.       <td><input type="submit" value="Insert record" /></td>
  101.     </tr>
  102.   </table>
  103.   <input type="hidden" name="user_Id" value="" />
  104.   <input type="hidden" name="uname_Id" value="" />
  105.   <input type="hidden" name="user_Id_fk" value="" />
  106.   <input type="hidden" name="uname_Id_fk" value="" />
  107.   <input type="hidden" name="uzip_Id" value="" />
  108.   <input type="hidden" name="MM_insert" value="form1" />
  109. </form>
  110. <p>&nbsp;</p>
  111. </body>
  112. </html>
  113.  
I know it can connect to the database is their another way i could do these mysql_select_db querys?

Thanks in advance for your help!
Feb 14 '09 #1
1 2438
wizardry
201 New Member
it's resolved. i changed th way i was connecting to the database but same select statements.
Feb 14 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3346
by: Oliv | last post by:
Bonjour, Est-il possible de se passer de l'instruction mysql_select_db() afin de sélectionner une base de données par défaut dans MySQL ? Je pense en particulier à l'association d'une base par...
7
2831
by: bettina | last post by:
Hello, I'm trying to connect a DB but I can't. Can anybody help me? Here is the piece of code... <?php $verbindung = mysql_connect("localhost", "coasters", ""); if (!$verbindung) { die('Not...
2
2412
by: Trev | last post by:
SQL Server 2000 BE, Access 2002 FE. I want to write a stored procedure, that will among other things log errors to a table, I want to be able to report a summary of work done and errors to the...
10
2287
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
0
2108
by: doli | last post by:
Hi, I have the following piece of code which iterates through the potential errors: i =0 For Each error_item in myConn.Errors DTSPackageLog.WriteStringToLog myConn.Errors(i).Description...
4
9823
by: johnb41 | last post by:
I have a form with a bunch of textboxes. Each text box gets validated with the ErrorProvider. I want the form to process something ONLY when all the textboxes are valid. I found a solution,...
24
5264
by: pat | last post by:
Hi everyone, I've got an exam in c++ in two days and one of the past questions is as follows. Identify 6 syntax and 2 possible runtime errors in this code: class demo {
8
5567
by: ImOk | last post by:
I just have a question about trapping and retrying errors especially file locking or database locks or duplicate key errors. Is there a way after you trap an error to retry the same line that...
2
1966
by: =?Utf-8?B?UmFuZHlz?= | last post by:
This just started when I updated to sp 1 working on a APS.net, Visual Studio 2008, c# Project. When I open a project, I get tons of Errors showing in the list 300+ if I double click on them I go...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.