mysql-error

Do you use mysql_error($con) or mysql_insert_id($con) to check insert result ?

$dml = "insert into table ..."; mysql_query($dml,$con); The above insert something into a table.then you can check if it succeeded by either if('' == mysql_error($con))... or if($id = mysql_insert_id($con))... What's your choice and reason? BTW,will the below still have $id fetched when running both of them,I've not tried yet: ...

How to log error queries in mysql?

I know that there is general_log that logs all queries, but I want to find out which query has an error, and get the error message. I have tried running an error query on purpose, but it logs as a normal query and doesn't report it with error. Any ideas? ...

Cannot add or update a child row: a foreign key constraint fails

// Getting the id of the restaurant to which we are uploading the pictures $restaurant_id = intval($_GET['restaurant-id']); if(isset($_POST['submit'])) { $tmp_files = $_FILES['rest_pics']['tmp_name']; $target_files = $_FILES['rest_pics']['name']; $tmp_target = array_combine($tmp_files, $target_files); $upload_dir = $rest...

Why can I query with an int but not a string here? PHP MySQL Datatypes

I am working on an Asset Database problem. I receive $id from $_GET["id"]; I then query the database and display the results. This works if my id is an integer like "93650" but if it has other characters like "wci1001", it displays this MySQL error: Unknown column 'text' in 'where clause' All fields in tables are of type: VARCHAR(50...

MySQL & PHP Parameter 1 as Resource

Alright, PHP is throwing this error at me (in the log) when I run the code mentioned below: Error mysql_num_rows() expects parameter 1 to be resource, string given in (place) on line 10 Line 9-11 $queryFP = ("SELECT * FROM db"); $countFP = mysql_num_rows($queryFP); $aID = rand(1, $countFP); I think it has something to do with the ...

Access denied for user 'root@localhost' (using password:NO)

I'm new to mysql, I'm trying to run Wordpress inmy windows desktop and it need Mysql. I install everything with Web Platform Installer which provided by microsoft. I never seta root password for mysql and in final step of installing wordpressit askfor root password of mysql. What is the default password for root (if there is one) and h...

IntegrityError when saving user with username=email

I have modified my application, so that when a new user is registered, it's username and email are the same. But when a new user is created, I'm getting IntegrityError : (1062, "Duplicate entry '[email protected]' for key 'username'"), still the user is created correctly. Function register_new in which a new user is created ('temp_data' is a ...

difference mysql_errno and mysql_error

Can any one Explain the difference mysql_errno and mysql_error ? Thanks in advance ...

Problem with a mysql query (like) and php

Hi! i'm trying to use the statement like of sql but unfortunately I get an error every time I use the query. In a php file I have: $b = "SELECT Nombre, Link, Img_Pre, Precio, Descripcion, ID, Categoria, Subcategoria FROM Productos WHERE Nombre LIKE \"%$a%\""; but i get this error: You have an error in your SQL syntax; check ...

A function to capture all MySQL errors?

Hi, Does anyone have a PHP function that for example if a mysql_error() happens due to well a MySQL error it will not output it? By not output it I mean rather it not show the error on live site as I will use it with another function I have that would work a treat if I had a MySQL error function. I am just finding it so annoying as I ...

000webhost sql server problem

I cannot figure out how to connect to the server with php 000webhost doesn't have localhost as their host name I tried to get it by doing one variable but it did not work when I tried to connect to the server with the code provided well I am writing an if statement that says if my site cannot connect then "die();" with the code provi...

MySQL foreign key to another foreign key

Hi. The idea is quite simple: i have three (or more) tables - master_tbl (id, something, somethingelse) - tbl2 (id, ....) - tbl3 (id, ....) Now what i want is a foreign key relationship, such as tbl3.id would point to tbl2.id and tbl2.id would point to master_tbl.id - all foreign keys are ON UPDATE CASCADE and ON DELETE CASCADE. What ...